Created
January 16, 2023 22:55
-
-
Save lslavkov/1e678687883cbe3e03c6c6dbe24d1d0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace enumExample | |
| { | |
| public class Program | |
| { | |
| // Prumer znamek | |
| enum GradeSystem | |
| { | |
| A = 100, | |
| B = 90, | |
| C = 80, | |
| D = 70, | |
| E = 60, | |
| F = 50 | |
| } | |
| static void Main(string[] args) | |
| { | |
| int[] scores = { 72, 16, 32, 89, 80, 81, 46, 90, 40 }; | |
| int sum = 0; | |
| for (int i = 0; i < scores.Length; i++) | |
| { | |
| sum += scores[i]; | |
| } | |
| double avg = (double)sum / (double)scores.Length; | |
| Console.WriteLine(AvgGradeDeclarer(avg)); | |
| } | |
| public static string AvgGradeDeclarer(double avg) | |
| { | |
| if (avg <= (int)GradeSystem.A && avg > (int)GradeSystem.B) | |
| { | |
| return "Average grade is A"; | |
| } | |
| else if (avg <= (int)GradeSystem.B && avg > (int)GradeSystem.C) | |
| { | |
| return "Average grade is B"; | |
| } | |
| else if (avg <= (int)GradeSystem.C && avg > (int)GradeSystem.D) | |
| { | |
| return "Average grade is C"; | |
| } | |
| else if (avg <= (int)GradeSystem.D && avg > (int)GradeSystem.E) | |
| { | |
| return "Average grade is D"; | |
| } | |
| else if (avg <= (int)GradeSystem.E && avg > (int)GradeSystem.F) | |
| { | |
| return "Average grade is E"; | |
| } | |
| else | |
| { | |
| return "Average grade is F"; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment