Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L06_NestedLoops;
- import java.util.Scanner;
- public class P04_TrainTheTrainers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int countPeople = Integer.parseInt(scanner.nextLine());
- String input = scanner.nextLine();
- int countGrades = 0;
- double sumAllGrades = 0;
- //while -> докато не получим Finish
- while (!input.equals("Finish")){
- double sumGradesPerPresentation = 0;
- // for -> прочитаме всяка една оценка
- for (int i = 1; i <= countPeople ; i++) {
- double currentGrade = Double.parseDouble(scanner.nextLine());
- sumGradesPerPresentation += currentGrade;
- //прибяваме currentGrade към sumAllGrades
- sumAllGrades += currentGrade;
- //увеличаваме броката на оценките
- countGrades++;
- }
- //изчисляваме средната оценка за презентация
- double averageGradePerPresentation = sumGradesPerPresentation / countPeople;
- System.out.printf("%s - %.2f.%n", input, averageGradePerPresentation);
- input = scanner.nextLine();
- }
- //изчисляваме средната оценка за вдички студенти
- double averageStudentsGrade = sumAllGrades / countGrades;
- System.out.printf("Student's final assessment is %.2f.", averageStudentsGrade);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement