Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. namespace fff
  2. {
  3.     using System;
  4.     class Program
  5.     {
  6.         public static void Main()
  7.         {
  8.             string name = string.Empty;
  9.  
  10.             while ((name = Console.ReadLine()) != "END")
  11.             {
  12.                 int yearInSchool = 0;
  13.                 int counter = 0;
  14.                 double sum = 0;
  15.                 bool isStuding = false;
  16.                 for (int i = 1; i <= 12; i++)
  17.                 {
  18.                     double grade = double.Parse(Console.ReadLine());
  19.  
  20.                     if (grade < 4.00)
  21.                     {
  22.                         counter++;
  23.                         isStuding = false;
  24.                         if (counter == 2)
  25.                         {
  26.                             yearInSchool++;
  27.                             i--;
  28.                             break;
  29.                         }                        
  30.                     }
  31.                     else
  32.                     {
  33.                         yearInSchool++;
  34.                         sum += grade;
  35.                         if (yearInSchool == 12)
  36.                         {
  37.                             isStuding = true;
  38.                             break;
  39.                         }
  40.                     }
  41.                 }
  42.                 double averageGrade = sum / 12;
  43.                 if (isStuding)
  44.                 {
  45.                     Console.WriteLine($"{name} graduated. Average grade: {averageGrade:f2}");
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine($"{name} has been excluded at {yearInSchool} grade");
  50.                 }
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement