对学生成绩大于60分的,输出“合格”。低于60分的,输出“不合格”。以下代码如何限制成绩最高100分。
System.out.println("输入成绩");
Scanner sc = new Scanner(System.in);
//对学生成绩大于60分的,输出“合格”。低于60分的,输出“不合格”。
int c = sc.nextInt();
if (c > 100) {
System.out.println("分数大于100,请检查!");
return;
}
switch (c / 60) { //定义switch语句
case 1:
System.out.println("及格");
break;
case 0:
System.out.println("不及格");
break;
}
下伪代码,写一个小程序,大于等于60分的输出“合格”,小于60分的输出“不合格”(C语言作业不懂求教!)
#include
int main()
{
float f;
printf("输入分数: ");
scanf("%f",f);
if(f>=60)
{
printf("及格");//可以换成自己的操作
}
else
{