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