Advertisement
GabrielHr00

04. Train The Trainers

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