Im writing a progam that calculate a person test score then prints out a letter grade bt i need to modify it so that the function "PrintGrade" actually keeps track of the highest score entered

this is what I have so far...

//This program reads a course score and prints the

#include <iostream>
#include <ctype.h>

using namespace std;

void getScore(int& );

int main ()
{
int courseScore, highest;
char choice;

cout << "Line 1: Based on the course score, \n"
<< " this program computes the "
<< "course grade." << endl; //Line 1
do {
getScore(courseScore); //Line 2

//Line 3

cout<<"Anymore scores(Y/N)?";
cin>>choice;

}while (toupper(choice) != 'N');

system("pause");
return 0;
}

void getScore(int& score)
{
cout << "Line 4: Enter course score: "; //Line 4
cin >> score; //Line 5
cout << endl << "Line 6: Course score is "
<< score << endl; //Line 6
}

void printGrade(int cScore, int & high)
{
cout << "Line 7: Your grade for the course is "; //Line 7

if (cScore >= 90) //Line 8
cout << "A." << endl;
else if (cScore >= 80)
cout << "B." << endl;
else if(cScore >= 70)
cout << "C." << endl;
else if (cScore >= 60)
cout << "D." << endl;
else
cout << "F." << endl;

cout<<"\nThe highest score thus far is: "<<high<<endl;
}

2
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by crosario90

First use code tags:

``````//This program reads a course score and prints the

#include <iostream>
#include <ctype.h>

using namespace std;

void getScore(int& );

int main ()
{
int courseScore, highest;
char choice;

cout << "Line 1: Based on the course score, \n"
<< " this program computes the "
<< "course grade." << endl; //Line 1
do {
getScore(courseScore); //Line 2

//Line 3

cout<<"Anymore scores(Y/N)?";
cin>>choice;

}while (toupper(choice) != 'N');

system("pause");
return 0;
}

void getScore(int& score)
{
cout << "Line 4: Enter course score: "; //Line 4
cin >> score; //Line 5
cout << endl << "Line 6: Course score is "
<< score << endl; //Line 6
}

void printGrade(int cScore, int & high)
{
cout << "Line 7: Your grade for the course is "; //Line 7

if (cScore >= 90) //Line 8
cout << "A." << endl;
else if (cScore >= 80)
cout << "B." << endl;
else if(cScore >= 70)
cout << "C." << endl;
else if (cScore >= 60)
cout << "D." << endl;
else
cout << "F." << endl;

cout<<"\nThe highest score thus far is: "<<high<<endl;
}``````

what are code tags?

Use an array to keep track of the highest score entered. This is an example.

``````#include <math.h>
int *list;
bool arrange(int length){

for(int i=0;i<length;i++)
{
if(list[i]>list[i+1])
swap(list[i],list[i+1]);

}

for(int i=0;i<length;i++)cout<<"my new list contains "<<list [i]<<endl;

return true;
}``````

Edited by alexchen: n/a

Code tags are used to post source code.

im not following along with the concept of swap