knikolov98

Untitled

Sep 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Graduation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string name = Console.ReadLine();
  10.             int grade = 12;
  11.             double input = 0.0;
  12.             int counter = 0;
  13.             double sum = 0;
  14.             int expelled = 0;
  15.  
  16.             while (counter < grade && expelled < 1)
  17.  
  18.             {
  19.                 input = double.Parse(Console.ReadLine());
  20.  
  21.                 while (input < 4.00)
  22.                 {
  23.                     input = double.Parse(Console.ReadLine());
  24.                     expelled++;
  25.  
  26.                     if (expelled >= 1)
  27.                     break;
  28.  
  29.                 }
  30.  
  31.                 sum += input;
  32.                  counter++;
  33.  
  34.             }
  35.  
  36.             if (expelled >= 1)
  37.  
  38.             {
  39.                 Console.WriteLine($"{name} has been excluded at {counter} grade");
  40.             }
  41.             else
  42.             {
  43.                 double average = sum / 12;
  44.                 Console.WriteLine($"{name} graduated. Average grade: {average:f2}");
  45.             }
  46.  
  47.             }
  48.     }
  49. }
Add Comment
Please, Sign In to add comment