package com.ctgu.java.exer; import java.util.Scanner; public class TestStudentScore { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("请输入学生的个数" ); int count = s.nextInt(); int[] scores =new int[count]; int maxScore = 0; System.out.println("请输入"+ count +"个成绩5" ); for(int i = 0; i<scores.length;i++){ int score = s.nextInt(); scores[i] = score; if(scores[i] > maxScore){ maxScore = scores[i]; } } System.out.println("最高分为:"+ maxScore); for(int i = 0;i < scores.length;i++){ char level; if( scores[i] >= maxScore-10){ level = ‘A‘; }else if( scores[i] >= maxScore-10){ level =‘B‘; }else if( scores[i] >= maxScore-20){ level = ‘C‘; }else{ level = ‘D‘; } System.out.println("student " +i+ " score is "+scores[i]+"5grade is "+ level); } // TODO Auto-generated method stub } }
原文地址:http://9815936.blog.51cto.com/9805936/1600886