Advertisement
GabrielHr00

04. Train The Trainers

Apr 14th, 2024
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. package _06_NestedLoops;
  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 gradersCount = Integer.parseInt(scanner.nextLine());
  9.  
  10.         double totalSum = 0.0;
  11.         int totalCount = 0;
  12.  
  13.         String command = scanner.nextLine();
  14.         while (!command.equals("Finish")) {
  15.             String presentationName = command;
  16.             double currentGradesSum = 0.0;
  17.  
  18.             for (int i = 1; i <= gradersCount; i++) {
  19.                 double grade = Double.parseDouble(scanner.nextLine());
  20.  
  21.                 currentGradesSum += grade;
  22.                 totalSum += grade;
  23.                 totalCount++;
  24.             }
  25.  
  26.             System.out.printf("%s - %.2f.%n", presentationName, currentGradesSum / gradersCount);
  27.             command = scanner.nextLine();
  28.         }
  29.  
  30.         System.out.printf("Student's final assessment is %.2f.", totalSum / totalCount);
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement