给定一个百分制的分数,输出相应的等级。
90分以上 A级 80~89 B级 70~79 C级 60~69 D级 60分以下 E级解决方法:
import java.util.*;class Mark{ public static void main(String []args){ System.out.println("please input marks:"); double mark; Scanner scanner = new Scanner(System.in); mark = scanner.nextDouble(); if(mark<0||mark>100){ System.out.println("输入有误!"); System.exit(0); } if(mark>=90) System.out.println("this mark is grade \'A\'"); else if(mark>=80) System.out.println("this mark is grade \'B\'"); else if(mark>=70) System.out.println("this mark is grade \'C\'"); else if(mark>=60) System.out.println("this mark is grade \'D\'"); else System.out.println("this mark is grade \'E\'"); }}