永发信息网

JAVA 成绩

答案:2  悬赏:0  手机版
解决时间 2021-02-21 01:23
  • 提问者网友:雨不眠的下
  • 2021-02-20 20:18
我自学不久 有个简单的学生成绩查询程序忘了 不适用SWITCH CASE就用if else就行
最佳答案
  • 五星知识达人网友:舊物识亽
  • 2021-02-20 21:21
你的意思是成绩在多少之间的查询是吧,
if(result<=100 && result>=90){
}else if(result<90 && result>=80){
}else if(result<80 && result>=70){
}else if(result<70 && result>=60){
}else if(result<60){
}
全部回答
  • 1楼网友:掌灯师
  • 2021-02-20 22:58

import java.util.scanner; import java.io.*;

public class score{     public static void main(string[] args){     int yw = sc("语文");     int sx = sc("数学");     fl("语文", yw);     fl("数学", sx);     }         public static int sc(string km){     system.out.print("请输入你的"+km+"成绩:");     scanner s = new scanner(system.in);     try{     return s.nextint();     } catch(exception e){     system.out.println("输入的值无效, 请重新输入!");     return sc(km);     }     }         public static void fl(string km, int sc){     system.out.print("你的" + km + "成绩为: ");     switch(sc){     case 1: case 2: case 3: case 4: case 5:     case 6: case 7: case 8: case 9: case 10:     case 11: case 12: case 13: case 14: case 15:     case 16: case 17: case 18: case 19: case 20:     system.out.println("1分"); break;     case 21: case 22: case 23: case 24: case 25:     case 26: case 27: case 28: case 29: case 30:     case 31: case 32: case 33: case 34: case 35:     case 36: case 37: case 38: case 39: case 40:     system.out.println("2分"); break;     case 41: case 42: case 43: case 44: case 45:     case 46: case 47: case 48: case 49: case 50:     case 51: case 52: case 53: case 54: case 55:     case 56: case 57: case 58: case 59: case 60:     system.out.println("3分"); break;     case 61: case 62: case 63: case 64: case 65:     case 66: case 67: case 68: case 69: case 70:     case 71: case 72: case 73: case 74: case 75:     case 76: case 77: case 78: case 79: case 80:     system.out.println("4分"); break;     case 81: case 82: case 83: case 84: case 85:     case 86: case 87: case 88: case 89: case 90:     case 91: case 92: case 93: case 94: case 95:     case 96: case 97: case 98: case 99: case 100:     system.out.println("5分"); break;     default: system.out.println("无效"); break;     }     } }

//想不通你为什么要用switch来判断

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯