Advertisement
MARINA_GREBENAROVA

Exam_Preparation

Oct 14th, 2021
1,478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exam_Preparation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int badGrades = int.Parse(Console.ReadLine());
  10.  
  11.             int count = 0;
  12.             string problemName = Console.ReadLine();
  13.             string lastProblem = "";
  14.             int gradeSum = 0;
  15.             int allGrades = 0;
  16.  
  17.            
  18.             while (problemName != "Enough")
  19.             {
  20.                 int currentGrade = int.Parse(Console.ReadLine());
  21.                 gradeSum++;
  22.                 allGrades += currentGrade;
  23.                 if (currentGrade <= 4)
  24.                 {
  25.                     count++;
  26.                     if (count == badGrades)
  27.                     {
  28.                         break;
  29.                     }
  30.  
  31.                 }
  32.                 lastProblem = problemName;
  33.                 problemName = Console.ReadLine();
  34.             }
  35.             if (problemName == "Enough")
  36.             {
  37.                 double averageScore = 1.0 * allGrades / gradeSum;
  38.  
  39.                 Console.WriteLine($"Average score: {averageScore:F2}");
  40.                 Console.WriteLine($"Number of problems: {gradeSum}");
  41.                 Console.WriteLine($"Last problem: {lastProblem}");
  42.             }
  43.             else
  44.             {
  45.                 Console.WriteLine($"You need a break, {count} poor grades.");
  46.             }
  47.  
  48.  
  49.         }
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement