package base;public class {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int score ;
score=91;
switch(score)
{
case (score>=90&&score>=100):System.out.println("优秀");break;
case (score>=80$$score<=89):System.out.println("良好");break;
case (score>=70$$score<=79):System.out.println("中等");break;
case (score>=60$$score<=69):System.out.println("及格");break;
case (score>=0$$score<=59):System.out.println("及格");break; }
}}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int score ;
score=91;
switch(score)
{
case (score>=90&&score>=100):System.out.println("优秀");break;
case (score>=80$$score<=89):System.out.println("良好");break;
case (score>=70$$score<=79):System.out.println("中等");break;
case (score>=60$$score<=69):System.out.println("及格");break;
case (score>=0$$score<=59):System.out.println("及格");break; }
}}
char ch = 'E';
if (i>=90) ch ='A';
if (80<=i<90) ch ='B';
if (70<=i<80) ch ='C';
if (60<=i<70) ch='D';
if (i<60) ch='E';
switch(ch){
case 'A':
break;
case 'B':
brak;
case 'C':
break;
case 'D':
break;
case 'E':
break;
} 要不就这样写了
不能用SWITCH
只能用if-else
if(...){
}else if(...)
{
}
else if(...)
{
}
...
else{
}
用if判断
还有score>=0$$score <=59)两个条件并起来用&&
好好看下书
public class {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int score ;
score = 91;
if(score>=90&&score>=100) {
System.out.println("优秀");
}
else if(score>=80&&score <=89) {
System.out.println("良好");
}
else if(score>=70&&score <=79) {
System.out.println("中等");
}
else if(score>=60&&score <=69) {
System.out.println("及格");
}
else if(score>=0&&score <=59) {
System.out.println("及格");
}
} }
{
case 9:System.out.println("优秀");break;
case 8:System.out.println("良好");break;
case 7:System.out.println("中等");break;
case 6:System.out.println("及格");break;
case 5:System.out.println("及格");break; }