+ 1

Can you help me make this code?

Create a Grade application that prompts the user for the percentage earned on a test or other graded work and then displays the corresponding letter grade. The application should use the grading scale at your school or the following grading scale: 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D below 60 F The application output should look similar to: Enter the percentage: 80 The corresponding letter grade is: B

14th Jan 2017, 12:03 AM
Bakary
6 Answers
+ 1
So, what do you have so far and where's the problem?
14th Jan 2017, 12:08 AM
Robobrine
Robobrine - avatar
+ 1
I didn't start it. It confusing to me. The problem is hard for me to understand.
14th Jan 2017, 12:25 AM
Bakary
+ 1
you can do It with if/else
14th Jan 2017, 12:30 AM
Kawaii
Kawaii - avatar
+ 1
What exactly? It shouldn't be hard, all you have to do is get some user input and then print out the corresponding grade using multiple if and else if statements.
14th Jan 2017, 12:31 AM
Robobrine
Robobrine - avatar
+ 1
static void Main(string[] args) { Console.WriteLine("Enter the percentage"); Run(); } static void Run() { try { Grade(Convert.ToInt16(Console.ReadLine())); } catch { Console.WriteLine("Please Enter a percentage between 1 - 100"); Run(); } } static void Grade(int percentage) { string grade; if (percentage < 60){grade = "F"; } else if (percentage > 60 && percentage < 69) { grade = "D"; } else if (percentage > 69 && percentage < 79) { grade = "C"; } else if (percentage > 79 && percentage < 89) { grade = "B"; } else if (percentage > 89 && percentage <= 100) { grade = "A"; } else { grade = ""; } if (percentage < 0 || percentage > 100) { Console.WriteLine("Please Enter a percentage between 1 - 100"); Run(); } else { Console.WriteLine("The corresponding letter grade is: " + grade); Console.ReadLine(); } }
14th Jan 2017, 4:46 AM
steven
steven - avatar
0
i did this some time ago #include <iostream> using namespace std; int main() { double score; cout << "Enter your grade scored in the programming class" << endl; cin >> score; if (score == 100) { cout << "You have a perfect score! Congratulations!!" << endl; } if (score >= 90 && score < 100) { cout << "You scored an A! Nice!" << endl; } if (score >= 80 && score <= 89) { cout << "You scored a B, not bad" << endl; } if (score >= 70 && score <= 79) { cout << "You scored a C, still not bad but you can get more" << endl; } if (score >= 60 && score <= 69) { cout << "You scored a D, you need to study more" << endl; } if (score >= 0 && score <= 59) { cout << "You scored a F, you are really bad" << endl; } return 0; }
14th Jan 2017, 12:33 AM
Kawaii
Kawaii - avatar