Aliendreamer

graduation part3

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