Advertisement
Dianov

While Loop - Lab (08. Graduation pt.2)

Dec 29th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 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 GraduationPt2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string name = Console.ReadLine();
  14.             int schoolClass = 1;
  15.             double grades = 0.00;
  16.  
  17.             while (true)
  18.             {
  19.                 double score = double.Parse(Console.ReadLine());
  20.                 if (score >= 4.00)
  21.                 {
  22.                     schoolClass += 1;
  23.                     grades += score;
  24.                 }
  25.                 else if (score < 4.00)
  26.                 {
  27.                     score = double.Parse(Console.ReadLine());
  28.                     if (score < 4.00)
  29.                     {
  30.                         Console.WriteLine($"{name} has been excluded at {schoolClass} grade");
  31.                         break;
  32.                     }
  33.                 }
  34.                 if (schoolClass == 13)
  35.                 {
  36.                     Console.WriteLine($"{name} graduated. Average grade: {(grades / 12):F2}");
  37.                     break;
  38.                 }
  39.             }
  40.         }  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement