Switch/Case Statement help!

/*This program uses a swith-case satement to assign a
letter grade (a, b, c, d, or f) to a numeric score.
I have to fix the problems in this program, I dont know how to
"fix" the actual cases...*/

#include <iostream>
using namespace std;

int main()
{
int testScore;
cout << "Enter your test score and i will tell you\n";
cout << "the letter grade you earned: ";
cin >> testScore;
switch (testScore)
{
case (testScore <= 60):
cout << "F\n";
break;
case (testScore <= 70.0):
cout << "D\n";
break;
case (testScore <= 80.0):
cout << "C\n";
break;
case (testScore <= 90.0):
cout << "B\n";
break;
case (testScore <= 100.0):
cout << "A\n";
break;

default:
cout << "That score isnt valid\n";

system("pause");
return 0;
}
Please use [code][/code] tags for your code.

(for future reference) What is happening, will it compile? Are you getting compiler warnings or errors? If it runs, what happens at run time?

Here's what I see:

switch statements don't accept conditions, only values (case 5: not case (a == 5): ).

The last thing is the whole system ("Pause"); thing:

http://cplusplus.com/articles/j3wTURfi/

To keep the console open:

http://cplusplus.com/articles/iw6AC542/
Topic archived. No new replies allowed.