0

I have difficulty to change the following program by using the array.

The display need to be like the following:

Result 1: 50.00 Grade U

Result 2: 95.60 Grade A

Result 3: 72.00 Grade B

Can anyone tell me how to do it?

Thanks.

```
#include <iostream>
#include <iomanip>
using namespace std;
float calc_average(float sum, int num);
void letter(float, int);
float score = 0;
int resultNum = 0;
int inputnum = 1; // for visual appeal
float avg = 0;
long sum = 0;
float high = 0;
float low = 100;
void main()
{
do
{
cout << "Enter result " << inputnum << " (or -1 if no more results) ";
cin >> score;
if (score<60)
cout << "Result " << resultNum << " is a U\n";
if (score>=60 && score<70)
cout << "Result " << resultNum << " is a C\n";
if (score>=70 && score<90)
cout << "Result " << resultNum << " is a B\n";
if (score>=90)
cout << "Result " << resultNum << " is a A\n";
if(score!=-1)
{
sum=sum+score; //save inputs before continuing
if (score>high)
high = score; //check for high grades
if (score<low)
low = score; //check for low grades
resultNum++; //used to divide average
inputnum++;
}
}while (score !=-1);
void letter(); //recieve grade
//calc_average function for beautiful clean code
cout << "The Average of the results = " << calc_average(sum,resultNum) << endl;
cout << "The Lowest of the results = " << low << endl;
cout << "The Highest of the results = " << high << endl;
}
float calc_average(float sum, int num)
{
return (sum/num);
}
```

*Edited 5 Years Ago by chuyauchi*: n/a