simonakancheva

Untitled

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