Advertisement
Dominusv2

Untitled

Dec 8th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Zadanie_nr_5_Wojciech_Wolosz
  6. {
  7.     class StudentGradeSheet
  8.     {
  9.         private double average;
  10.         Dictionary<string, double> GradeSheet = new Dictionary<string, double>()
  11.         {
  12.             {"Maths", 0 },
  13.             {"Algebra", 0 },
  14.             {"Geometry", 0 },
  15.             {"Science", 0  },
  16.             {"Biology", 0},
  17.             {"Physics", 0},
  18.             {"Chemistry", 0},
  19.             {"Geography", 0 },
  20.             {"History", 0 },
  21.             {"Citizenship", 0 },
  22.             {"P.E", 0 },
  23.         };
  24.         public void AddGrade (string key, double value)
  25.         {
  26.             if(value >= 0 && value <= 6)
  27.                 {
  28.                 GradeSheet.Add(key, value);
  29.                 }
  30.             else
  31.             {
  32.                 Console.WriteLine("The grade is out of range");
  33.             }
  34.         }
  35.         public void ShowGrade (string key)
  36.         {
  37.             Console.WriteLine(GradeSheet[key]);
  38.         }
  39.         public double Average()
  40.         {
  41.             foreach(KeyValuePair<string, double> para in GradeSheet)
  42.             {
  43.                 average = average + para.Value;
  44.             }
  45.             Console.WriteLine(average / GradeSheet.Count);
  46.             return average = average/GradeSheet.Count;
  47.         }
  48.         public void IfPass()
  49.         {
  50.             if (average >= 3.0)
  51.             {
  52.                 Console.WriteLine("This student is passing the semester");
  53.             }
  54.             else
  55.             {
  56.                 Console.WriteLine("This student is not passing the semester");
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement