Guest User

Untitled

a guest
May 8th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2.  
  3. class Grades
  4. {
  5.     static void Main()
  6.     {
  7.         int students = int.Parse(Console.ReadLine());
  8.  
  9.         int weakStudents = 0;
  10.         int averageStudents = 0;
  11.         int veryGoodStudents = 0;
  12.         int excellentStudents = 0;
  13.  
  14.         decimal averageEvaluation = 0;
  15.  
  16.         for (int i = 0; i < students; i++)
  17.         {
  18.             decimal evaluation = decimal.Parse(Console.ReadLine());
  19.  
  20.             if (evaluation >= 2.00M && evaluation <= 2.99M)
  21.             {
  22.                 weakStudents++;
  23.             }
  24.             else if (evaluation >= 3.00M && evaluation <= 3.99M)
  25.             {
  26.                 averageStudents++;
  27.             }
  28.             else if (evaluation >= 4.00M && evaluation <= 4.99M)
  29.             {
  30.                 veryGoodStudents++;
  31.             }
  32.             else if (evaluation >= 5.00M)
  33.             {
  34.                 excellentStudents++;
  35.             }
  36.  
  37.             averageEvaluation += evaluation;
  38.         }
  39.  
  40.         averageEvaluation /= students;
  41.  
  42.         decimal weakStudentsPercent = ((decimal)weakStudents / students) * 100;
  43.         decimal averageStudentsPercent = ((decimal)averageStudents / students) * 100;
  44.         decimal veryGoodStudentsPercent = ((decimal)veryGoodStudents / students) * 100;
  45.         decimal excellentStudentsPercent = ((decimal)excellentStudents / students) * 100;
  46.  
  47.         Console.WriteLine("Top students: {0:F2}%", excellentStudentsPercent);
  48.         Console.WriteLine("Between 4.00 and 4.99: {0:F2}%", veryGoodStudentsPercent);
  49.         Console.WriteLine("Between 3.00 and 3.99: {0:F2}%", averageStudentsPercent);
  50.         Console.WriteLine("Fail: {0:F2}%", weakStudentsPercent);
  51.         Console.WriteLine("Average: {0:F2}", averageEvaluation);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment