Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02.ExamPreparation
- {
- class ExamPreparation
- {
- static void Main(string[] args)
- {
- int failedThreshold = int.Parse(Console.ReadLine());
- int failedTimes = 0;
- int solvedProblemsCount = 0;
- double gradeSum = 0;
- string lastProblem = "";
- bool isFailed = true;
- while (failedTimes < failedThreshold)
- {
- string problemName = Console.ReadLine();
- if ("Enough" == problemName)
- {
- isFailed = false;
- break;
- }
- int grade = int.Parse(Console.ReadLine());
- if (grade <= 4)
- {
- failedTimes++;
- }
- gradeSum += grade;
- solvedProblemsCount++;
- lastProblem = problemName;
- }
- if (isFailed)
- {
- Console.WriteLine($"You need a break, {failedThreshold} poor grades.");
- }
- else
- {
- double avg = gradeSum / solvedProblemsCount;
- Console.WriteLine($"Average score: {avg:f2}");
- Console.WriteLine($"Number of problems: {solvedProblemsCount}");
- Console.WriteLine($"Last problem: {lastProblem}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment