I'm trying to create this program for a school project, but I keep getting errors using the switch option in the code itself. Is there a reason why this happens? Here is the code:
switch (studentId); // no semicolons here
{
case 1234:
...
} //end switch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
if (grade >= '89.5')
cout << "A";
elseif (grade >= '84.5')
cout << "B+";
elseif (grade >= '79.5')
cout << "B";
elseif (grade >= '74.5')
cout << "C+";
elseif (grade >= '69.5')
cout << "C";
elseif (grade >= '64.5')
cout << "D+";
elseif (grade >= '59.5) // remember to end apostrophes
cout << "D";
else if (grade <= '59.4) // im not sure if apostrophe is correct word
cout << "F";
else //default
cout << "Invalid Grade";
//end if
chars like that wont work anyway. '74.5' you cant check if something is bigger than that :P. those signs can only store 1 character like 'h'. so cin >> grade; will just store the first letter i think. just try storing the input in double and checking for numbers. if you want to store multiple letters use the quotation marks char smth[10] = "hello"; Looking forward to the cookies.