SHARE
TWEET

Exam Preparation

a guest Oct 14th, 2018 332 in 28 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace _02.Exam_Preparation
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int unsatisfactoryGrades = int.Parse(Console.ReadLine());
  10.             string command = Console.ReadLine();
  11.  
  12.             int currentNumberUnsatisfactoryŠssessments = 0;
  13.             int numberOfProblems = 0;
  14.             string lastProblem = string.Empty;
  15.             double sum = 0;
  16.  
  17.             bool isEnough = true;
  18.             while (command != "Enough")
  19.             {
  20.                 numberOfProblems++;
  21.                 string nameTask = command;
  22.                 lastProblem = nameTask;
  23.  
  24.                 int grade = int.Parse(Console.ReadLine());
  25.                 sum += grade;
  26.                 if (grade <= 4)
  27.                 {
  28.                     currentNumberUnsatisfactoryŠssessments++;
  29.                 }
  30.  
  31.                 if (currentNumberUnsatisfactoryŠssessments == unsatisfactoryGrades)
  32.                 {
  33.                     isEnough = false;
  34.                     break;
  35.                 }
  36.                 command = Console.ReadLine();
  37.             }
  38.  
  39.             if (isEnough)
  40.             {
  41.                 Console.WriteLine($"Average score: {sum / numberOfProblems:f2}");
  42.                 Console.WriteLine($"Number of problems: {numberOfProblems}");
  43.                 Console.WriteLine($"Last problem: {lastProblem}");
  44.             }
  45.             else
  46.             {
  47.                 Console.WriteLine($"You need a break, {unsatisfactoryGrades} poor grades.");
  48.             }
  49.         }
  50.     }
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top