Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TrainTheTrainers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // read count of graders
- int juryCount = Integer.parseInt(scanner.nextLine());
- // save grades total count and total sum
- double allGradesSum = 0.0;
- int allGradesCount = 0;
- String command = scanner.nextLine();
- while(!command.equals("Finish")) {
- String presentationName = command;
- // save grades only for current presentation
- double gradeSumCurrentPres = 0.0;
- for (int i = 1; i <= juryCount; i++) {
- // read grade
- double grade = Double.parseDouble(scanner.nextLine());
- // increment the count of all grades
- allGradesCount++;
- // add grade to the total sum of grades
- allGradesSum = allGradesSum + grade;
- // add grade to current average grade sum
- gradeSumCurrentPres = gradeSumCurrentPres + grade;
- }
- // print average grade for the current presentation
- System.out.printf("%s - %.2f.%n", presentationName, gradeSumCurrentPres/juryCount);
- command = scanner.nextLine();
- }
- // print final average
- System.out.printf("Student's final assessment is %.2f.", allGradesSum/allGradesCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement