Advertisement
veronikaaa86

04. Train The Trainers

Jul 11th, 2021
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package nestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04TrainTheTrainers {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(scanner.nextLine());
  10.  
  11. String input = scanner.nextLine();
  12.  
  13. double totalSumGrades = 0;
  14. int countGrades = 0;
  15.  
  16. while (!input.equals("Finish")) {
  17. String presentationName = input;
  18.  
  19. double sumCurrentGrades = 0;
  20. for (int i = 1; i <= n; i++) {
  21. double grade = Double.parseDouble(scanner.nextLine());
  22. countGrades++;
  23. sumCurrentGrades = sumCurrentGrades + grade;
  24. }
  25. totalSumGrades = 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.%n", totalSumGrades / countGrades);
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement