nikolayneykov

Untitled

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