Advertisement
fbinnzhivko

Problem 04. Grades

Dec 21st, 2016
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.Remoting.Channels;
  4.  
  5. namespace ConsoleApplication
  6. {
  7.     internal class Program
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.             var n = decimal.Parse(Console.ReadLine());
  12.  
  13.             var topStudentCounter = 0;
  14.             var goodCounter = 0;
  15.             var almostCounter = 0;
  16.             var fail = 0;
  17.  
  18.             decimal x = 0;
  19.  
  20.             for (int i = 0; i < n; i++)
  21.             {
  22.                 decimal grade = decimal.Parse(Console.ReadLine());
  23.                 x += grade;
  24.  
  25.                 if (grade >= (decimal) 5.00)
  26.                 {
  27.                     topStudentCounter++;
  28.                 }
  29.                 else if (grade >= (decimal) 4.00 && grade <= (decimal) 4.99)
  30.                 {
  31.                     goodCounter++;
  32.                 }
  33.                 else if (grade >= (decimal) 3.00 && grade <= (decimal) 3.99)
  34.                 {
  35.                     almostCounter++;
  36.                 }
  37.                 else
  38.                 {
  39.                     fail++;
  40.                 }
  41.             }
  42.             Console.WriteLine("Top students: {0:f2}%",(100/n)*topStudentCounter);
  43.             Console.WriteLine("Between 4.00 and 4.99: {0:f2}%",(100/n)*goodCounter);
  44.             Console.WriteLine("Between 3.00 and 3.99: {0:f2}%",(100/n)*almostCounter);
  45.             Console.WriteLine("Fail: {0:f2}%",(100/n)*fail);
  46.             Console.WriteLine("Average: {0:f2}",x/n);
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement