alexbancheva

Train_the_trainers_Nested_Loops_Exercise

Dec 2nd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Train_the_trainers_Nested_Loops_Exercise
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             double counter = 0;
  11.             double allScore = 0;
  12.  
  13.             //string nameOfPres = Console.ReadLine();
  14.             //string marks = Console.ReadLine();
  15.  
  16.             while (true)
  17.             {
  18.                 string nameOfPres = Console.ReadLine();
  19.                 double sumOfGrades = 0;
  20.  
  21.                 if (nameOfPres == "Finish")
  22.                 {
  23.                     double scoreSum = allScore / counter;
  24.                     Console.WriteLine($"Student's final assessment is {scoreSum:f2}.");
  25.                     break;
  26.                 }
  27.                 for (int i = 0; i < n; i++)
  28.                 {
  29.                     double grade = double.Parse(Console.ReadLine());
  30.                     sumOfGrades += grade;
  31.                     allScore += grade;
  32.                     counter++;
  33.                 }
  34.                 double sumAfter = sumOfGrades / n;
  35.                 Console.WriteLine($"{nameOfPres} - {sumAfter:f2}.");
  36.  
  37.             }
  38.         }
  39.     }
  40. }
Add Comment
Please, Sign In to add comment