编程,把百分制成绩转换成5级记分制,要求用switch语句.
发布网友
发布时间:2022-04-26 17:06
我来回答
共3个回答
热心网友
时间:2023-05-19 07:46
具体方法与演示结果如图:
热心网友
时间:2023-05-19 07:47
#include "stdio.h"
void main()
{
int i,score;
char band;
for(i=0;i<5;i++)
{
printf("Input Score:");
scanf("%d",&score);
switch(score/10)
{
case 10:
case 9: band='A'; break;
case 8: band='B'; break;
case 7: band='C'; break;
case 6: band='D'; break;
default: band='E'; break;
}
printf("%d的等级为%c\n",score,band);
}
}
热心网友
时间:2023-05-19 07:47
Scanner sc = new Scanner(System.in);
System.out.print("请输入成绩:");
int score = sc.nextInt();
System.out.println();
String print;
switch (score/10) {
case 9:
print = "A";
break;
case 8:
print = "B";
break;
case 7:
print = "C";
break;
case 6:
print = "D";
break;
default:
print = "F";
break;
}
System.out.println(score+"等级为"+print);