Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2. Grades
- Write a method that receives a grade between 2.00 and 6.00 and prints the corresponding grade in words
- • 2.00 – 2.99 - "Fail"
- • 3.00 – 3.49 - "Poor"
- • 3.50 – 4.49 - "Good"
- • 4.50 – 5.49 - "Very good"
- • 5.50 – 6.00 - "Excellent"
- Examples
- Input Output
- 3.33 Poor
- 4.50 Very good
- 2.99 Fail
- using System;
- namespace _02MethodsLabGrades
- {
- class Program
- {
- static void Main(string[] args)
- {
- var grade = double.Parse(Console.ReadLine());
- PrintAsWords(grade);
- }
- static void PrintAsWords(double grade)
- {
- if (grade >= 2.00 && grade <= 2.99)
- {
- Console.WriteLine("Fail");
- }
- else if (grade >= 3.00 && grade <= 3.49)
- {
- Console.WriteLine("Poor");
- }
- else if (grade >= 3.50 && grade <= 4.49)
- {
- Console.WriteLine("Good");
- }
- else if (grade >= 4.50 && grade <= 5.49)
- {
- Console.WriteLine("Very good");
- }
- else if(grade >= 5.50 && grade <= 6.00)
- {
- Console.WriteLine("Excellent");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment