This is an edited version of the original program.
****Right question is how would I get this to loop if the condition of x is not between 0-100..... i've tried the following which doesn't work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
//Grading system
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"Please enter your grade results between 0-100:";
cout<<endl;
cin>>x;
cin.ignore();
do {
if (x < 60)
cout<< "You got an F";
cout<<endl;
else if (x < 70)
cout<< "You got a D";
cout<<endl;
else if (x < 80)
cout<< "You got a C, not bad";
cout<<endl;
else if (x < 90)
cout<< "You got a B, good work";
cout<<endl;
else if (x < 100)
cout<< "You got an A, great work!";
cout<<endl;
else if (x == 100)
cout<< "You got a perfect score A*";
cout<<endl;
else
cout<< "Sorry please enter a valid number between 0-100";
cout<<endl;
} while ( x ! < 101);
cin.get();
}
|
****Also is it possible to make the else if something more along the line of for example:
1 2 3
|
else if (x <=99) {
cout<< "Well done you got an A!";
}
|
****meaning less than or equal to or even better how would it be possible to have an else if between two variable integer for example
1 2 3
|
else if (x <=99||>89) {
cout<< "well done you got an A!";
}
|
****Meaning less than or equal to 99 but greater than 89.. I know some of this coding is wrong it is shown as an example of what I am trying to achieve...
Do you see where i'm going wrong? apart from having along string of messy else if.
I've even tried the following:
1 2 3 4 5
|
if (x >= 0 && x <= 59)
cout<< "You got an F";
cout<<endl;
else if (x >= 60 && x <= 69)
cout<< "You got a D";
|
etc etc
trying to meet these conditions:
Write a program that allows the user to enter the grade scored in a programming class (0-100).
If the user scored a 100 then notify the user that they got a perfect score.
★ Modify the program so that if the user scored a 90-100 it informs the user that they scored an A
★★ Modify the program so that it will notify the user of their letter grade
0-59 F 60-69 D 70-79 C 80-89 B 90-100 A