Help with a program

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2007
Posts: 3
Reputation: tony71 is an unknown quantity at this point 
Solved Threads: 0
tony71 tony71 is offline Offline
Newbie Poster

Help with a program

 
0
  #1
May 8th, 2007
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!

  1. #include <iostream>
  2. using namespace std;
  3. int get_letter grade(int);
  4. int main()
  5. {
  6. int numeric_grade,
  7. letter_grade;
  8.  
  9. cout << " Enter the exam grade: " ;
  10. cin >> numeric_grade;
  11. cout endl;
  12. letter_grade = get_letter grade(numeric_grade);
  13. cout <<endl;
  14. cout <<" The letter grade is "<< letter_grade << endl;
  15. cout << endl;
  16.  
  17. return 0;
  18. }
  19. int get_letter grade ( numeric_grade)
  20.  
  21. {
  22. ((10- (grade/10)) + 64)
  23. return;
  24.  
  25. }
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...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Help with a program

 
2
  #2
May 8th, 2007
Your get_letter grade function has a space in its name, and the implementation doesn't return anything.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Help with a program

 
0
  #3
May 8th, 2007
>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.
"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.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: tony71 is an unknown quantity at this point 
Solved Threads: 0
tony71 tony71 is offline Offline
Newbie Poster

Re: Help with a program

 
0
  #4
May 9th, 2007
I did the changes but still having issues.
:-(
  1. #include <iostream>
  2. using namespace std;
  3. int Exam_Grade(int);
  4. int main()
  5. {
  6. int numeric_grade;
  7. char letter_grade;
  8. cout << " Enter the exam grade: ";
  9. cin >> numeric_grade;
  10. cout endl;
  11. letter_grade= Exam_Grade(numeric_grade);
  12. cout<<endl;
  13. cout <<" The letter grade is "<< letter_grade << endl;
  14. cout << endl;
  15. return 0;
  16. }
  17. int Exam_Grade(int numeric)
  18. {
  19. double grade;
  20. grade= ((10- (grade/10)) + 64);
  21.  
  22.  
  23. return grade;
  24. }
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...
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Help with a program

 
0
  #5
May 9th, 2007
>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".
"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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Help with a program

 
0
  #6
May 9th, 2007
>I did the changes but still having issues.
It would be nice if you told us what those issues were.

>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...
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: iTaChi is an unknown quantity at this point 
Solved Threads: 2
iTaChi's Avatar
iTaChi iTaChi is offline Offline
Newbie Poster

Re: Help with a program

 
0
  #7
May 9th, 2007
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!
"If you understand, you can learn anything"


http://www.cprogrammingdock.serverspeople.net
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: tony71 is an unknown quantity at this point 
Solved Threads: 0
tony71 tony71 is offline Offline
Newbie Poster

Re: Help with a program

 
0
  #8
May 10th, 2007
Thanks guys. I got it! One thing I was missing << like Joe mentioned. :-)

And I changed grade to numeric and that worked.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC