knikolov98

Untitled

Oct 15th, 2019
63
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
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.  
  11.             int n = int.Parse(Console.ReadLine());
  12.             decimal grade = 0.0m;
  13.             decimal avg = 0.0m;
  14.             decimal avgGrade = 0.0m;
  15.             int Nstudents = 0;
  16.  
  17.             string input = string.Empty;
  18.             string subject = string.Empty;
  19.  
  20.  
  21.             while (input != "Finish")
  22.             {
  23.                 subject = Console.ReadLine();
  24.                 avgGrade = 0;
  25.  
  26.                 if (input == "Finish" || subject == "Finish")
  27.                 {
  28.                     break;
  29.                 }
  30.  
  31.                 for (int i = 0; i < n; i++)
  32.                 {
  33.  
  34.                    input = Console.ReadLine();
  35.                         grade = decimal.Parse(input);
  36.  
  37.                     avgGrade += grade / n;
  38.                         avg += grade;
  39.  
  40.  
  41.                     Nstudents++;
  42.                 }
  43.  
  44.                 Console.WriteLine($"{subject:f2} - {avgGrade:f2}.");
  45.             }
  46.  
  47.             avg /= Nstudents;
  48.             Console.WriteLine($"Student's final assessment is {avg:f2}.");
  49.  
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment