Krasimir_Slavov

Untitled

Oct 6th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 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.             double average = allGrade / 12;
  37.             Console.WriteLine($"{student} graduated. Average grade: {average:F2}");
  38.  
  39.  
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment