Advertisement
knikolov98

Untitled

Sep 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2.  
  3. namespace grades_2nd_try
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int badGrades = int.Parse(Console.ReadLine());
  10.             int counterbadGrades = 0;
  11.             int counterGrades = 0;
  12.             string lastSubject = string.Empty;
  13.             int grade = 0;
  14.             double sumGrades = 0;
  15.             int totalGrades = 0;
  16.  
  17.             string input = String.Empty;
  18.  
  19.             while (input != "Enough" && counterbadGrades < badGrades)
  20.  
  21.             {
  22.                 // lastSubject = input;
  23.                 input = Console.ReadLine();
  24.  
  25.  
  26.                 if (input == "Enough")
  27.                     break;
  28.  
  29.                 lastSubject = input;
  30.  
  31.                 grade = int.Parse(Console.ReadLine());
  32.  
  33.                 if (grade <= 4)
  34.                 {
  35.                     counterbadGrades++;
  36.                     sumGrades += grade;
  37.                 }
  38.                 else
  39.                 {
  40.                     sumGrades += grade;
  41.                     counterGrades++;
  42.                 }
  43.  
  44.  
  45.             }
  46.             totalGrades = counterGrades + counterbadGrades;
  47.             double average = sumGrades / totalGrades;
  48.  
  49.             if (input == "Enough")
  50.  
  51.             {
  52.                 Console.WriteLine($"Average score: {average:F2}");
  53.                 Console.WriteLine($"Number of problems: {totalGrades}");
  54.                 Console.WriteLine($"Last problem: {lastSubject}");
  55.             }
  56.  
  57.             else
  58.             {
  59.                 Console.WriteLine($"You need a break, {badGrades} poor grades.");
  60.             }
  61.  
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement