public class Prog5{ public static void main(String[] args){ int n = -1; try{ n = Integer.parseInt(args[0]); }catch(ArrayIndexOutOfBoundsException e){ [size=10.5000pt] [size=10.5000pt] [size=10.5000pt] System.out.println("请输入成绩"); return; } grade(n); } [size=10.5000pt] //成绩等级计算 private static void grade(int n){ if(n>100 || n<0) [size=10.5000pt] [size=10.5000pt] System.out.println("输入无效"); else{ [size=10.5000pt] [size=10.5000pt] String str = (n>=90)?"分,属于A等":((n>60)?"分,属于B等":"分,属于C等"); System.out.println(n+str); } } } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |