nikolayneykov

Untitled

Oct 8th, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. class ExamPreparation
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int poorGradeLimit = int.Parse(Console.ReadLine());
  8.         int poorGradeCount = 0;
  9.         int problemCount = 0;
  10.         double gradesSum = 0;
  11.         string lastProblemName = string.Empty;
  12.         string problemName = string.Empty;
  13.         while (poorGradeCount < poorGradeLimit &&
  14.             (problemName = Console.ReadLine()) != "Enough")
  15.         {
  16.             double grade = double.Parse(Console.ReadLine());
  17.             gradesSum += grade;
  18.             problemCount++;
  19.             lastProblemName = problemName;
  20.             if (grade <= 4.00)
  21.             {
  22.                 poorGradeCount++;
  23.             }
  24.         }
  25.         Console.WriteLine(poorGradeCount < poorGradeLimit ?
  26.             $"Average score: {gradesSum / problemCount:F2}" +
  27.             $"\nNumber of problems: {problemCount}" +
  28.             $"\nLast problem: {lastProblemName}" :
  29.             $"You need a break, {poorGradeCount} poor grades.");
  30.     }
  31. }
Add Comment
Please, Sign In to add comment