Advertisement
GabrielHr00

TrainTheTrainers

Dec 5th, 2022
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TrainTheTrainers {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. // read count of graders
  7. int juryCount = Integer.parseInt(scanner.nextLine());
  8.  
  9. // save grades total count and total sum
  10. double allGradesSum = 0.0;
  11. int allGradesCount = 0;
  12.  
  13. String command = scanner.nextLine();
  14. while(!command.equals("Finish")) {
  15. String presentationName = command;
  16.  
  17. // save grades only for current presentation
  18. double gradeSumCurrentPres = 0.0;
  19. for (int i = 1; i <= juryCount; i++) {
  20. // read grade
  21. double grade = Double.parseDouble(scanner.nextLine());
  22. // increment the count of all grades
  23. allGradesCount++;
  24. // add grade to the total sum of grades
  25. allGradesSum = allGradesSum + grade;
  26. // add grade to current average grade sum
  27. gradeSumCurrentPres = gradeSumCurrentPres + grade;
  28. }
  29.  
  30. // print average grade for the current presentation
  31. System.out.printf("%s - %.2f.%n", presentationName, gradeSumCurrentPres/juryCount);
  32. command = scanner.nextLine();
  33. }
  34.  
  35. // print final average
  36. System.out.printf("Student's final assessment is %.2f.", allGradesSum/allGradesCount);
  37. }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement