public class cjzh {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double cj;
System.out.println("请输入数字");
cj = sc.nextDouble();
String pf;
int grade = (int) (cj / 10);//将cj转换为int类型除以10取整
switch (grade) {
case 6:
if (cj > 60 && cj <= 69) {//整型60~69除以10取整都为6,还可进行范围判定
pf = "D";
System.out.println(cj + "\t" + pf);
}
break;
case 7:
if (cj >= 70 && cj <= 79) {//整型70~79除以10取整都为7
pf = "C";
System.out.println(cj + "\t" + pf);
}
break;
case 8:
if (cj >= 80 && cj <= 89) {//整型80~89除以10取整都为8
pf = "B";
System.out.println(cj + "\t" + pf);
}
break;
case 9:
if (cj >= 90 && cj <= 100) {//整型90~99除以10取整都为9
pf = "A";
System.out.println(cj + "\t" + pf);
}
break;
case 10:
if (cj >= 90 && cj <= 100) {//整型100除以10取整为10
pf = "A";
System.out.println(cj + "\t" + pf);
}
break;
default:
pf = "E";
System.out.println(cj + "\t" + pf);//cj<60
break;
}
/*方法2:使用switch进入选择,进行分数判断,进行输出分级制评分
* switch (pf) { case
* "E":if(cj>=0&&cj<=59){pf="E";System.out.println(cj+"\t"+pf);} case
* "D":if(cj>60&&cj<=69){pf="D";System.out.println(cj+"\t"+pf);} case
* "C":if(cj>=70&&cj<=79){pf="C";System.out.println(cj+"\t"+pf);} case
* "B":if(cj>=80&&cj<=89){pf="B";System.out.println(cj+"\t"+pf);} case
* "A":if(cj>=90&&cj<=100){pf="A";System.out.println(cj+"\t"+pf);}
* break;
*
* default: break; }
*/
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double cj;
System.out.println("请输入数字");
cj = sc.nextDouble();
String pf;
int grade = (int) (cj / 10);//将cj转换为int类型除以10取整
switch (grade) {
case 6:
if (cj > 60 && cj <= 69) {//整型60~69除以10取整都为6,还可进行范围判定
pf = "D";
System.out.println(cj + "\t" + pf);
}
break;
case 7:
if (cj >= 70 && cj <= 79) {//整型70~79除以10取整都为7
pf = "C";
System.out.println(cj + "\t" + pf);
}
break;
case 8:
if (cj >= 80 && cj <= 89) {//整型80~89除以10取整都为8
pf = "B";
System.out.println(cj + "\t" + pf);
}
break;
case 9:
if (cj >= 90 && cj <= 100) {//整型90~99除以10取整都为9
pf = "A";
System.out.println(cj + "\t" + pf);
}
break;
case 10:
if (cj >= 90 && cj <= 100) {//整型100除以10取整为10
pf = "A";
System.out.println(cj + "\t" + pf);
}
break;
default:
pf = "E";
System.out.println(cj + "\t" + pf);//cj<60
break;
}
/*方法2:使用switch进入选择,进行分数判断,进行输出分级制评分
* switch (pf) { case
* "E":if(cj>=0&&cj<=59){pf="E";System.out.println(cj+"\t"+pf);} case
* "D":if(cj>60&&cj<=69){pf="D";System.out.println(cj+"\t"+pf);} case
* "C":if(cj>=70&&cj<=79){pf="C";System.out.println(cj+"\t"+pf);} case
* "B":if(cj>=80&&cj<=89){pf="B";System.out.println(cj+"\t"+pf);} case
* "A":if(cj>=90&&cj<=100){pf="A";System.out.println(cj+"\t"+pf);}
* break;
*
* default: break; }
*/
}
}