nikolayneykov

Untitled

Oct 8th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 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 currentClass = 1;
  11.             double totalGrades = 0;
  12.             int exclude = 0;
  13.  
  14.             while (currentClass <= 12)
  15.             {
  16.                 double grade = double.Parse(Console.ReadLine());
  17.  
  18.                 if (grade < 4.00)
  19.                 {
  20.                     ++exclude;
  21.                     if (exclude > 1)
  22.                     {
  23.                         Console.WriteLine($"{name} has been excluded at {currentClass} grade");
  24.                         break;
  25.                     }
  26.                 }
  27.                 else if (grade >= 4.00)
  28.                 {
  29.                     totalGrades += grade;
  30.                     currentClass++;
  31.                 }
  32.             }
  33.             double averageGrade = totalGrades / 12.0;
  34.             if (exclude == 0)
  35.             {
  36.                 Console.WriteLine($"{name} graduated. Average grade: {averageGrade:F2}");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment