Java Problem Summary 16-one-dimensional array case
Read the student score from the keyboard, find the highest score, and output the student grade.
Score >= Highest Score-10 grade is ' A '
Score >= Highest score-20 grade for ' B '
Score >= Highest score-30 grade for ' C '
The remaining levels are ' D '
Tip: Read the number of students first, create an int array based on the number of people, and store student scores
Code:
Package Java3;import Java.util.scanner;public class scores {public static void main (string[] args) { Scanner s = new Scanner (system.in); system.out.println ("Please enter student number"); int all= S.nextint (); system.out.println ("Please input" +all+ "Students ' scores"); int[] Ss=new Int[all]; int max=0; for (int i=0;i<all;i++) { ss[i ]=s.nextint (); if (ss[i]>max) { max=ss[i]; } } System.out.println ("Highest score:" +max); for (int i=0;i<all;i++) { int j=i+1; if (ss[i]>=max-10) { system.out.println ("+j+" Student's score is "+ss[i]+" Grade: A "); &NBSP;} else if (ss[i]>=max-20) { system.out.println ("+j+" Student's score is "+ss[i]+" Grade: B "); } else if (ss[i]>=max-30) { System.out.println ("+j+" Student's score is "+ss[i]+" level: C "); }else{ system.out.println ("+j+" Student's score is "+ss[i]+" Grade: D "); } } }}
Results:
Please enter the number of Students 5 Please enter the 5 student's score 5674894189 the highest score is: 89 The 1 students ' grade is 56 grade: The 2nd student's grade is 74 Grade: B 3rd student's grade is 89 grade: A 4th schoolmate's grade is 41 grade: D 5th schoolmate's grade is 89 grade: a
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Problem Summary 16-one-dimensional array case