Advertisement
YORDAN2347

ExamPreparation

Nov 29th, 2020 (edited)
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ExamPreparation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int poorGrades = int.Parse(Console.ReadLine());
  10.             string problemName = "";
  11.  
  12.             int problems = 0;
  13.             int fails = 0;
  14.             double sum = 0;
  15.             string lastProblem = "";
  16.  
  17.             bool isEnough = false;
  18.  
  19.             while (!isEnough)
  20.             {
  21.                 problemName = Console.ReadLine();
  22.  
  23.                 if (problemName == "Enough")
  24.                 {
  25.                     isEnough = true;
  26.                     break;
  27.  
  28.                 }
  29.  
  30.                 int problemGrade = int.Parse(Console.ReadLine());
  31.                 sum += problemGrade;
  32.                 problems++;
  33.  
  34.                 if (problemGrade <= 4)
  35.                 {
  36.                     fails++;
  37.                 }
  38.  
  39.                 if (fails >= poorGrades)
  40.                 {
  41.                    
  42.                     isEnough = true;
  43.                 }
  44.                 lastProblem = problemName;
  45.             }
  46.  
  47.             if (problemName == "Enough")
  48.             {
  49.                 Console.WriteLine($"Average score: {sum / problems:f2}");
  50.                 Console.WriteLine($"Number of problems: {problems}");
  51.                 Console.WriteLine($"Last problem: {lastProblem}");
  52.             }
  53.             else
  54.             {
  55.                 Console.WriteLine($"You need a break, {fails} poor grades.");
  56.             }
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement