Java Problem Summary 16-one-dimensional array case

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.