simonakancheva

ExamPreparation

Apr 7th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ExamPreparation
  8.  
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             int possibleBadGrades = int.Parse(Console.ReadLine());
  16.             int badGradesCount = 0;
  17.             int total = 0;
  18.             double sum = 0;
  19.                        
  20.             string lastProblem =string.Empty;
  21.             while (badGradesCount < possibleBadGrades)
  22.             {
  23.                 string command = Console.ReadLine();
  24.                 int grade = int.Parse(Console.ReadLine());
  25.                 if (command=="Enough")
  26.                 {
  27.                     break;
  28.                 }
  29.                 int currentGrade = int.Parse(Console.ReadLine());
  30.                 lastProblem = command;
  31.                 total++;
  32.                 sum += currentGrade;
  33.                 if (currentGrade<=4)
  34.                 {
  35.                     badGradesCount++;
  36.                 }
  37.             }
  38.             if (badGradesCount==possibleBadGrades)
  39.             {
  40.                 Console.WriteLine($"You need a break, {badGradesCount} poor grades.");
  41.             }
  42.             else
  43.             {
  44.                 double average = sum / total;
  45.  
  46.                 Console.WriteLine($"Average score: {average:f2}");
  47.                 Console.WriteLine($"Number of problem: {total}");
  48.                 Console.WriteLine($"Last problem: {lastProblem}");
  49.  
  50.             }
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment