I need help with the char function where i have to take the % and change it to the corresponding grade . and also the output function which has to look like this , we use setw()
Code:
----------------------------
| EXAM | SCORE | GRADE |
----------------------------
| HIGH | 100 | A |
----------------------------
| AVG | 83 | B |
----------------------------
| LOW | 61 | D |
----------------------------
| 1 | 100 | A |
----------------------------
| 2 | 73 | C |
----------------------------
| 3 | 94 | A |
----------------------------
| 4 | 61 | D |
----------------------------
| 5 | 87 | B |
----------------------------
# include <iostream.h>
# include <iomanip.h>
# include <math.h>
// This program asks the user to enter a series of test scores //
// Then it will determine the highest , lowest , and average scores//
// The corresponding letter grade will be assigned to the scores//
// And finally a table of output will be displayed//
// ***** VARIABLE DECLARATIONS ******//
int promptscore (void);
void displayoutput (int[], int );
char examgrade (int);
int avggrade ( int[], int );
int highestgrade ( int [], int );
int lowestgrade (int [] , int );
void clearscreen (void);
const int maxels = 8; //maximum # of array elements
int examscore [maxels];
//****** MAIN PROGRAM BODY *************//
main ()
{
int score , i = 0;
clearscreen();
score = promptscore();
while (score = 0 && i < maxels )
{
examscore[i++] = score;
if ( i < maxels )
score = promptscore();
}
displayoutput(examscore , i);
}
//****** THIS IS THE PROMPT FOR SCORE FUNCTION******//
int promptscore(void)
{
int examscore;
cout << " enter score , enter a negative number to quit : ";
cin >> examscore;
return examscore;
// ******* THIS IS THE FUNCTION FOR HIGHEST GRADE *******//
int highestgrade ( int exam [], int nbrofexams)
{
int i , highestgrade;
highestgrade= exam[0];
for ( i = 0; i < nbrofexams; i++)
{
if (exam[i] > highestgrade)
highestgrade = exam[i];
}
}
// ********** THIS IS THE LOWEST SCORE FUNCTION ********//
int lowestgrade ( int exam [], int nbrofexams)
{
int i , lowestgrade;
lowestgrade= exam[0];
for ( i = 0; i < nbrofexams; i ++ )
{
if( exam [i] < lowestgrade)
lowestgrade = exam[i];
}
}
//*** THIS IS THE INCOMPLETE !!!!!!! AVERAGE GRADE FUNCTION *****//
float averagegrade ( int grade [] , int n )
{
int sum = 0;
for ( int i = 0 ; i < n; i ++ )
sum += grade [i];
return (sum) / n;
}
//!!!!!!!!!!!!! CHAR EXAM GRADE FUNCTION !!!!!!!!!!!!!!//
// !!!!!!!!!!!!!! CLEAR SCREEN FUNCTION !!!!!!!!!!!!!!!!!!//
void clearscreen(void)
{
cout << "\033[2j\033[h";
}
// !!!!!!!!!!!!! DISPLAY OUTPUT FUNCTION !!!!!!!!!!!!!!!!!!!!!!//