Java enters student scores from the keyboard, finds the highest score, and outputs the student grade.

Source: Internet
Author: User

/ * 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.

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.