amazingme001
07-27-2005, 05:58 AM
gif if anyone could help me with this problem, I would greatly appreciate it!
I have to use value-returning function so it computes and returns the course grade(must be output in the main() ) . So far I have program written as a void function. What would be the next step?
here is the code:
// Program: Compute grade.This program reads a course score and prints the
// associated course grade.
#include <iostream>
#include "EXAMPLE07.H" // my headerfile
using namespace std;
void getScore(int& score);
void printGrade(int score);
int main ()
{
int courseScore;
cout<<"Line 1: Based on the course score, this program "
<<"computes the course grade."<<endl;
getScore(courseScore);
printGrade(courseScore);
return 0;
}
void getScore(int& score)
{
cout<<"Line 4: Enter course score--> ";
cin>>score;
cout<<endl<<" Course score is "
<<score<<endl;
}
void printGrade(int score)
{
cout<<"Your grade for the course is ";
if(score >= 90)
cout<<"A"<<endl;
else if(score >= 80)
cout<<"B"<<endl;
else if(score >= 70)
cout<<"C"<<endl;
else if(score >= 60)
cout<<"D"<<endl;
else
cout<<"F"<<endl;
}
p.s. I'll keep on trying to figure it out
I have to use value-returning function so it computes and returns the course grade(must be output in the main() ) . So far I have program written as a void function. What would be the next step?
here is the code:
// Program: Compute grade.This program reads a course score and prints the
// associated course grade.
#include <iostream>
#include "EXAMPLE07.H" // my headerfile
using namespace std;
void getScore(int& score);
void printGrade(int score);
int main ()
{
int courseScore;
cout<<"Line 1: Based on the course score, this program "
<<"computes the course grade."<<endl;
getScore(courseScore);
printGrade(courseScore);
return 0;
}
void getScore(int& score)
{
cout<<"Line 4: Enter course score--> ";
cin>>score;
cout<<endl<<" Course score is "
<<score<<endl;
}
void printGrade(int score)
{
cout<<"Your grade for the course is ";
if(score >= 90)
cout<<"A"<<endl;
else if(score >= 80)
cout<<"B"<<endl;
else if(score >= 70)
cout<<"C"<<endl;
else if(score >= 60)
cout<<"D"<<endl;
else
cout<<"F"<<endl;
}
p.s. I'll keep on trying to figure it out