help please

i need help with this assignment assignment 3 the function printGrade in example 5-10 is written as a void function to compute and output the course grade the course score is passed as a parameter to the function printGrade rewrite the function printGrade as a returning function so that it computes and returns the course grade. (the course grade must be output in the function main.) also change the name of the function to calculateGrade.

here is the 5-10 example
http://books.google.com/books?id=4Fn_P7tdOZgC&pg=PA279&lpg=PA279&dq=introduction+to+c%2B%2B+example+5-10+ds+malik&source=bl&ots=gTtNYGmwtL&sig=Ntfld3AQqE-AMlf_yY8KPTw0nCU&hl=en&sa=X&ei=QXGUT8fPFYPN6QH_4K25BA&ved=0CCIQ6AEwAA#v=onepage&q&f=false
here is what i have so far i dont want someone to do the assignment for me but just offer help


#include <iostream>
using namespace std;

void getScore(int& score);
char calculateGrade(char ch);
char grade;

int main()
{
int courseScore;

cout << "Based on the course score, \n"
<< " this program computes the "
<< "course grade. " << endl;

getScore (courseScore);
calculateGrade (courseScore);

return 0;
}
void getScore (int& score)
{
cout << "Enter course score: ";
cin >> score;
cout << endl << "Course score is "
<< score << endl;
}
calculateGrade (int cScore)
{ // here is my error ISO C++ forbids declaration of 'calculateGrade' with no type in function int calculateGrade(int) invalid conversion from const char* to char
if (cScore >= 90)
grade = "A";
else if (cScore >= 80)
grade = "B";
else if (cScore >= 70)
grade = "C";
else if (cScore >= 60)
grade = "D";
else grade = "F";
return grade;
}

First off, if you want to become a programmer, learn some proper grammar. Second, please use code wrap and indent your code so it's easier for us to read.

First off, on the linecalculateGrade (int cScore) you need to add char before it, so you declare it as a char.
Second, why are you using a function to get the user input? Just have them input it in main. I know that's what it does in the example, but I don't really see a use for it in this program.
Third, when returning something in a situation like this, you want to cout the function. Like this:
1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
     cout << returnANumber(5);
}

int returnANumber(int num)
{
     if(num < 10)
        return 0;
     else if(num >= 10)
        return 1;
}


This would output 1.
okay first i know proper grammar i didnt use it second i have to use whats in the example because thats what the assignment says and im new to the forums and dont know how to code wrap
Topic archived. No new replies allowed.