Advertisement
Dimo1985

Untitled

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