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
//associated course grade.

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

using namespace std;

void getScore(int& );
void printGrade(int , 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

printGrade(courseScore, highest);
//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;
}

First use code tags:

//This program reads a course score and prints the
//associated course grade.

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

using namespace std;

void getScore(int& );
void printGrade(int , 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

printGrade(courseScore, highest);
//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;
}

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 5 Years Ago by alexchen: n/a

This article has been dead for over six months. Start a new discussion instead.