| | |
Help with a program
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 0
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!
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!
c Syntax (Toggle Plain Text)
#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; }
Last edited by WaltP; May 10th, 2007 at 1:10 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
>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
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. "Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 0
I did the changes but still having issues.
:-(
:-(
c Syntax (Toggle Plain Text)
#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; }
Last edited by WaltP; May 10th, 2007 at 1:11 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
>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".
>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".
"Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
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!
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!
![]() |
Similar Threads
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- What's the HARDEST program you've written? (Computer Science)
- Cool little Program to disable startup programs (Windows NT / 2000 / XP)
- Program is shutting down right after program is executed (C++)
- 3d Program (Game Development)
Other Threads in the C++ Forum
- Previous Thread: C++ help (string class)
- Next Thread: problem with system() function...
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






