Advertisement
Dido09

TrainTheTrainers

Oct 23rd, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 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.  
  7. int people = Integer.parseInt(scanner.nextLine());
  8. String namePresent = scanner.nextLine();
  9.  
  10. double averageGrade = 0;
  11. double gradeCounter = 0;
  12. double counter = 0;
  13. double sumGrade = 0;
  14. double allGrade = 0;
  15. while (!namePresent.equals("Finish")) {
  16. sumGrade = 0;
  17. for (gradeCounter = 1.00; gradeCounter <= people; gradeCounter++) {
  18. double grade = Double.parseDouble(scanner.nextLine());
  19.  
  20. allGrade += grade;
  21. sumGrade += grade;
  22. counter++;
  23. if (gradeCounter == people) {
  24. averageGrade = sumGrade / people;
  25. break;
  26. }
  27. }
  28. if (!namePresent.equals("Finish")) {
  29. System.out.printf("%s - %.2f.%n", namePresent, averageGrade);
  30. }
  31. namePresent = scanner.nextLine();
  32. }
  33. if (namePresent.equals("Finish")) {
  34.  
  35. double totalGrade = allGrade / counter;
  36. System.out.printf("Student's final assessment is %.2f.", totalGrade);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement