Joreto

P04TrainTheTrainers

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