Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Zadanie_nr_5_Wojciech_Wolosz
- {
- class StudentGradeSheet
- {
- private double average;
- Dictionary<string, double> GradeSheet = new Dictionary<string, double>()
- {
- {"Maths", 0 },
- {"Algebra", 0 },
- {"Geometry", 0 },
- {"Science", 0 },
- {"Biology", 0},
- {"Physics", 0},
- {"Chemistry", 0},
- {"Geography", 0 },
- {"History", 0 },
- {"Citizenship", 0 },
- {"P.E", 0 },
- };
- public void AddGrade (string key, double value)
- {
- if(value >= 0 && value <= 6)
- {
- GradeSheet.Add(key, value);
- }
- else
- {
- Console.WriteLine("The grade is out of range");
- }
- }
- public void ShowGrade (string key)
- {
- Console.WriteLine(GradeSheet[key]);
- }
- public double Average()
- {
- foreach(KeyValuePair<string, double> para in GradeSheet)
- {
- average = average + para.Value;
- }
- Console.WriteLine(average / GradeSheet.Count);
- return average = average/GradeSheet.Count;
- }
- public void IfPass()
- {
- if (average >= 3.0)
- {
- Console.WriteLine("This student is passing the semester");
- }
- else
- {
- Console.WriteLine("This student is not passing the semester");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement