Java program, the average score of students

Source: Internet
Author: User

The first step, the system prompts to enter the number of participants.

The second step is to get the students ' scores and accumulate them.

The third step is to find the average score and output.

Import Java.util.scanner;public class Chengji{public static void Main (string[] args) {Scanner s=new Scanner (system.in); System.out.println ("Please enter the number of participants"), int renshu=s.nextint (); int i=1;int Sum=0;while (I<=renshu) {System.out.println (" Please enter "+i+" Student's score: "); Scanner a=new Scanner (system.in); int b=a.nextint (); sum=sum+b;i++;} int Avg=sum/renshu; System.out.println (renshu+ "the average student's score is" +avg);}}

  

C:\Documents and Settings\administrator>d:

D:\>CD JAVACX

D:\javacx>javac Chengji.java

D:\javacx>java Chengji
Please enter the number of participants
5
Please enter the 1th participant's score:
90
Please enter the 2nd participant's score:
80
Please enter the 3rd participant's score:
70
Please enter the 4th participant's score:
60
Please enter the 5th participant's score:
50
The average score for 5 participants was 70.

Java program, the average score of students

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.