Advertisement
veronikaaa86

04. Train The Trainers

Dec 5th, 2021
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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. double allGradesSum = 0;
  12. int allGradesCount = 0;
  13.  
  14. String input = scanner.nextLine();
  15. while (!input.equals("Finish")) {
  16. String presentationName = input;
  17.  
  18. double currentGradesSum = 0;
  19. for (int i = 0; i < n; i++) {
  20. double currentGrade = Double.parseDouble(scanner.nextLine());
  21. allGradesCount++;
  22.  
  23. currentGradesSum = currentGradesSum + currentGrade;
  24. }
  25.  
  26. allGradesSum = allGradesSum + currentGradesSum;
  27.  
  28. System.out.printf("%s - %.2f.%n", presentationName, currentGradesSum / n);
  29.  
  30. input = scanner.nextLine();
  31. }
  32.  
  33. System.out.printf("Student's final assessment is %.2f.%n", allGradesSum / allGradesCount);
  34. }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement