/ * Enter student scores from the keyboard, find the highest score, and output the student grade;
Score >= Highest score-10 Grade A
Score >= Highest score-20 grade B
Score >= Highest score-30 Class C
The rest is grade D
Tip: First enter the number of students, according to the number of people to create an array of int, store student scores;
*/
Packagestudy01;ImportJava.util.Scanner; Public classScore { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); System.out.print ("Please enter the number of students:"); intLength =Sc.nextint (); int[] scores =New int[length]; intMaxscore = 0; for(inti = 0; i < scores.length; i++) {Scores[i]=Sc.nextint (); if(Scores[i] >Maxscore) {Maxscore=Scores[i]; }} System.out.println ("Highest Score" +Maxscore); System.out.println ("The results entered are:"); for(inti = 0; i < scores.length; i++) { CharLevel ; if(Scores[i] > maxScore-10) { level= ' A '; } Else if(Scores[i] > maxScore-20) { level= ' B '; } Else if(Scores[i] > maxScore-30) { level= ' C '; } Else{ level= ' D '; } System.out.println ("student[" +i+ "score is" +scores[i]+ "grade" +Level ); } }}
The output results are as follows:
Please enter the number of students: 6
90
70
80
50
60
40
Highest score 90
The results entered are:
Student[0] Score is all grade is A
STUDENT[1] Score is-grade is C
STUDENT[2] Score is a grade is B
STUDENT[3] score is grade is D
STUDENT[4] Score is a grade is D
STUDENT[5] Score is + grade is D
Java enters student scores from the keyboard, finds the highest score, and outputs the student grade.