This is a simple program designed to output the grade a student earned by inputting score. My only problem is "Molly (case sensitive) is the teacher's special favorite, so if she earns less than an A, her grade is promoted to the next higher grade". I can't figure out how to make that possible with an if statement or switch statement. So for example, if Molly's score were to be 40 her grade outputted would be a D. Here is my code
(1) If you don't care about the actual score, but want it to just increase the letter grade then:
if (score<90)
{ score+=10 }
(2) If you care about the actual numerical score, then:
(A) Check if it is less than 90
(B) Check if it is less than 60 (If it is, then set it to 60. If not, move on to C)
(C) Check/convert to an int or round it
(D) The number now must be between 60 and 89. Now, convert to a string.
(E) Check the 1st character and set it accordingly. So, if:
if (score[0]=='6')
{ int n=70; }
if (score[0]=='7')
{ int n=80; }
if (score[0]=='8')
{ int n=90; }
@kemort I tried that and it works to an extent as in my program outputs both "Molly gets a D" and "Molly gets an F". What should i alter so the second statement does not appear.
As a quick thought without checking you have to change Molly's score before performing the 'swindle' because even though the grade will change the score will still produce the old grade.