import java.util.Scanner;
public class Main
{
public static int n;
public static String module;
public static int [] scores;
public static void getInput(){
Scanner in=new Scanner(System.in);
System.out.println("Enter the name of the module: ");
module=in.next();
System.out.println("Enter the number of students: ");
n=in.nextInt();
}
public static void accumulate_result(){
scores =new int [n];
int x=n;
Scanner in=new Scanner(System.in);
System.out.println("Enter the scores of the students:");
for(int i=0;i<x;i++){
scores[i]=in.nextInt();
}
}
public static int average_result(){
int avg;
int sum=0;
for(int i=0;i<n;i++){
sum+=scores[i];
}
avg=sum/n;
return avg;
}
public static void results_report(){
System.out.println("Module name: "+module);
System.out.println("Number of students: "+n);
System.out.println("Average score: "+average_result());
System.out.println("Results of the student:");
for(int i=0;i<n;i++){
System.out.println("Student"+(i+1)+" score: "+scores[i]);
}
}
public static void main(String[] args) {
getInput();
accumulate_result();
results_report();
}
}
Comments
Leave a comment