Having trouble with this assignment can anybody give my a hint as to where I should start?

Write a program that prints letter grades based on a score (between 0 and 10) entered from the keyboard.
The simplified scoring system will be:
9-10 A
8 B
7 B-
6 C+
5 C
4 D+
0-3 F

Write two functions: if_grade and switch-grade. Both will take the integer score as input and print the letter grade. The if_grade function will accomplish this with if-else, the switch with a switch statement.

{
if (grade >= 9 && < 10)
return 'A';
else if (grade == 8)
return 'B';

[etc...]
}

{
{
case '10':
return 'A';
case '9':
return 'A';
case '8':
return 'B';

[etc...]
}
}

that should be enogh help

So I got this far but I'm missing something simple I can't get the program to print B-, C+, C- and D+. If I put in B- It just print - (minus) like I have in my original question.

``````#include <iostream>
using namespace std;

{
if ((Num < 0) || (Num > 10))
else if (Num >= 9)
else if (Num >= 8)
else if (Num >= 7)
else if (Num >= 6)
else if (Num >= 5)
else if (Num >= 4)
else
}

{
switch(Num)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
case 10:
break;
}
}

int main()
{
int number;
cout << " Please enter an integer from 0-10" << endl;
cin >> number;
cout << " The grade is: " << grades << endl;
system("pause");
return 0;
}``````

change char to string, and add the + and - in the quotes

Hmm I changed everything to string and it's still print just - or +

``````#include <iostream>
using namespace std;
{
if ((Num < 0) || (Num > 10))
else if (Num >= 9)
else if (Num >= 8)
else if (Num >= 7)
else if (Num >= 6)
else if (Num >= 5)
else if (Num >= 4)
else
}

{
switch(Num)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
case 10:
break;
}
}
int main()
{
int number;
cout << " Please enter an integer from 0-10" << endl;
cin >> number;
cout << " The grade is: " << grades << endl;
system("PAUSE");
return EXIT_SUCCESS;
return 0;
}``````

if you work with strings I think you need to put the string into " " quotation marks and not '.

Bah he failed my code I'm not sure what is wrong but I hae been given another chance to amend it. I really donb't know what the problem is maybe someone can tell me?

These are his comments:
your program only prints the letter equivalent for the if method, but not for the switch method.

Assuming you put quotation marks around the strings the only thing I see missing is the output at the end.

``cout << " The grade is: " << grades << endl;``

This only gives you the string from the if-method.

``cout << " The grade is (if-method): " << grades << "       The grade is (switch-method): " << switch_grades   << endl;``

I'd be willing to help if I could read your code. You need to format it so all of us can see what you are doing -- including you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.