veronikaaa86

04. Train The Trainers

Mar 14th, 2021
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04TrainTheTrainers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         String input = scanner.nextLine();
  10.  
  11.         double totalSumGrades = 0;
  12.         int countGrades = 0;
  13.         while (!input.equals("Finish")){
  14.             String presentationName = input;
  15.  
  16.             double sumCurrentGrades = 0;
  17.             for (int i = 1; i <= n; i++) {
  18.                 double grade = Double.parseDouble(scanner.nextLine());
  19.  
  20.                 countGrades++;
  21.  
  22.                 sumCurrentGrades += grade;
  23.             }
  24.  
  25.             totalSumGrades += sumCurrentGrades;
  26.  
  27.             System.out.printf("%s - %.2f.%n", presentationName, sumCurrentGrades / n);
  28.  
  29.             input = scanner.nextLine();
  30.         }
  31.  
  32.         System.out.printf("Student's final assessment is %.2f.", totalSumGrades / countGrades);
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment