Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void exit()
- {
- Environment.Exit(0);
- }
- static void Main(string[] args)
- {
- // main
- assign_grade();
- // main //
- }
- static string assign_grade()
- {
- string[] grades = new string[6] { "A", "B+", "B", "C+", "C", "D" };
- int max_score;
- int your_score;
- Console.WriteLine("enter the max score of your test");
- max_score = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("enter your score");
- your_score = Convert.ToInt32(Console.ReadLine());
- if (your_score > max_score)
- {
- Console.WriteLine("Why are you lying, press any key to exit the program");
- Console.ReadKey();
- exit();
- }
- if (your_score >= max_score * 0.9)
- {
- Console.WriteLine("Your grade is: " + grades[0]);
- Console.ReadKey();
- return grades[0];
- }
- if (your_score < max_score * 0.9 && your_score >= max_score * 0.8)
- {
- Console.WriteLine("Your grade is: " + grades[1]);
- Console.ReadKey();
- return grades[1];
- }
- if (your_score < max_score * 0.8 && your_score >= max_score * 0.7)
- {
- Console.WriteLine("Your grade is: " + grades[2]);
- Console.ReadKey();
- return grades[2];
- }
- if (your_score < max_score * 0.7 && your_score >= max_score * 0.6)
- {
- Console.WriteLine("Your grade is: " + grades[3]);
- Console.ReadKey();
- return grades[3];
- }
- if (your_score < max_score * 0.6 && your_score >= max_score * 0.5)
- {
- Console.WriteLine("Your grade is: " + grades[4]);
- Console.ReadKey();
- return grades[4];
- }
- if (your_score <= max_score * 0.5)
- {
- Console.WriteLine("Your grade is: " + grades[5]);
- Console.ReadKey();
- return grades[5];
- }
- else
- {
- Console.WriteLine("Wrong input");
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement