#include <iostream>
usingnamespace std;
int main()
{
int nScore;
cout << "Please enter your score: ";
cin >> nScore;
switch(nScore){
case(WHAT WOULD I WRITE HERE?):
cout << "With a score between 0-59 you are graded an F."<<endl;
break;
default:
cout << endl;
}
system("pause");
return 0;
}
or would I have to nest if statements inside this? still trying to figure out logic in c++ lol.
int nScore;
cout << "Please enter your score: ";
cin >> nScore;
if(nScore >=0 && nScore < 60)
{
cout << "With a score between 0-59 you are graded an E."<<endl;
}
else if (nScore >= 60 && nScore < 70)
{
cout << "With a score between 60-69 you are graded an D."<<endl;
}
else if (nScore >=70 && nScore < 80)
{
cout << "With a score between 70-79 you are graded a C."<<endl;
}
else if (nScore >=80 && nScore < 90)
{
cout << "With a score between 80-89 you are graded a B."<<endl;
}
else if (nScore >=90 && nScore < 101)
{
cout << "With a score between 90-100 you are graded a A."<<endl;
}
else
{
cout << "Please enter a valid score!" << endl;
}
system("pause");
return 0;
}
Ok so this works, is there a more optimized way around this?