Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace grades_2nd_try
- {
- class Program
- {
- static void Main(string[] args)
- {
- int badGrades = int.Parse(Console.ReadLine());
- int counterbadGrades = 0;
- int counterGrades = 0;
- string lastSubject = string.Empty;
- int grade = 0;
- double sumGrades = 0;
- int totalGrades = 0;
- string input = String.Empty;
- while (input != "Enough" && counterbadGrades < badGrades)
- {
- // lastSubject = input;
- input = Console.ReadLine();
- if (input == "Enough")
- break;
- lastSubject = input;
- grade = int.Parse(Console.ReadLine());
- if (grade <= 4)
- {
- counterbadGrades++;
- sumGrades += grade;
- }
- else
- {
- sumGrades += grade;
- counterGrades++;
- }
- }
- totalGrades = counterGrades + counterbadGrades;
- double average = sumGrades / totalGrades;
- if (input == "Enough")
- {
- Console.WriteLine($"Average score: {average:F2}");
- Console.WriteLine($"Number of problems: {totalGrades}");
- Console.WriteLine($"Last problem: {lastSubject}");
- }
- else
- {
- Console.WriteLine($"You need a break, {badGrades} poor grades.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement