HI guys,

I am taking C++ and I'm suppose to write this program where it asks the user to input a grade that they recieved in their exam . The grade is an interger from 0 to 100. Basicly the program should convert the numeric grade to a letter grade.

I have written the program and I only get two errors and can't figure it out and its driving me crazy. can someone please help me? Thanks!

#include <iostream>
using namespace std;
int get_letter grade(int);
int main()
{
 int numeric_grade,
        letter_grade;
 
 cout << " Enter the exam grade: " ;
    cin >> numeric_grade;
    cout endl;
 letter_grade = get_letter grade(numeric_grade);
  cout <<endl;
  cout <<" The letter grade is "<< letter_grade << endl;
  cout << endl;

  return 0;
}
int get_letter grade ( numeric_grade)
 
{
 ((10- (grade/10)) + 64)
return;

}

>int get_letter grade(int);
Can't have spaces in your function. And since you're calculating a letter grade, don't you think you had better return a letter instead of a number?

>int numeric_grade,
>letter_grade;
Likewise, you should make 'letter_grade' a char value, not an integer. It just makes sense.

>cout endl;
There's something special that needs to go between these...

>((10- (grade/10)) + 64)
>return;
Put the return keyword before the expression.

I did the changes but still having issues.
:-(

#include <iostream>
using namespace std;
int Exam_Grade(int);
int main()
{
 int numeric_grade;
char letter_grade;
cout << " Enter the exam grade: ";
cin >> numeric_grade;
cout endl;
letter_grade= Exam_Grade(numeric_grade); 
cout<<endl;
cout <<" The letter grade is "<< letter_grade << endl;
cout << endl;
return 0;
}
int Exam_Grade(int numeric)
{
 double grade;
grade= ((10- (grade/10)) + 64);
 
 
 return grade;
}

>double grade;
>grade= ((10- (grade/10)) + 64);
If you never use a parameter of the function to calculate the grade, what makes you think it'll be calculated correctly?

>cout endl;
Again, I remind you: there is something that needs to go between "cout" and "endl".

>I did the changes but still having issues.
It would be nice if you told us what those issues were. :icon_rolleyes:

>cout endl;
That won't compile. You probably meant cout<<endl; .

>grade= ((10- (grade/10)) + 64);
grade doesn't have a predictable value but you use it in an expression...

in declaring and defining functions, you should know that there should be no whitespaces in the name,

also, you should assign the correct data type to a variable you declared, if you want it to function as a character, you should assign it as a char type.

good luck!

Thanks guys. I got it! One thing I was missing << like Joe mentioned. :-)

And I changed grade to numeric and that worked.

This question has already been answered. Start a new discussion instead.