nikolayneykov

Untitled

Oct 11th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. class Graduationpt2
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string studentName = Console.ReadLine();
  8.         double gradeSum = 0;
  9.         bool isExcluded = false;
  10.         int count = 1;
  11.         while (count <= 12)
  12.         {
  13.             double grade = double.Parse(Console.ReadLine());
  14.             if (grade >= 4.00)
  15.             {
  16.                 gradeSum += grade;
  17.                 count++;
  18.             }
  19.             else
  20.             {
  21.                 isExcluded = true;
  22.                 break;
  23.             }
  24.         }
  25.         double averageGrade = gradeSum / 12;
  26.  
  27.         Console.WriteLine(isExcluded ?
  28.             $"{studentName} has been excluded at {count} grade" :
  29.             $"{studentName} graduated. Average grade: {averageGrade:F2}");
  30.     }
  31. }
Add Comment
Please, Sign In to add comment