赞
踩
将学生的考试成绩转换成不同的等级:90分以上为A,80分以上90分以下为B,70分以上80分以下为C,60分以上70分以下为D,E表示不及格。
import java.io.*; public class welcome{ public static void main(String[] args) throws IOException{ int ch; InputStreamReader ir; BufferedReader in; ir=new InputStreamReader(System.in); in=new BufferedReader(ir); System.out.print("input ch is: "); String s=in.readLine(); ch=Integer.parseInt(s); char grade; ch=ch/10; switch(ch) { case 9:grade='A'; break; case 8:grade='B'; break; case 7:grade='C'; break; case 6:grade='D'; break; default:grade='E'; } System.out.println("grade = "+grade); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。