I have been working on this for a very long time. I have also searched for examples but they do not help.
Here is what i need to do...I need to take the students score and compare it to average and print out the corresponding grade. I am having a hard time doing that. I would appreciate any help or direction, please. The out put is also included

Here is my code.

``````#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>

using namespace std;

float computeAverage(int scores[], int count);
void printTable(int id[], int scores[], int count);

const int MAX_SIZE = 21;

int main()
{
string file;
int scores[MAX_SIZE];
int id[MAX_SIZE];
int i , count = 0, oneScore = 0;
float avg = 0, average = 0;
bool tooMany;

//Open file
cout << "\nEnter input filename: ";
cin >> file;

computeAverage(scores,count);
printTable(id,scores,count);

if (tooMany = true)
{
cout << "\nAverage score is: " << computeAverage(scores,count) << "%" << endl;
cout << "\n***Array is filled! Remaining scores will not be stored.***";
cout << endl;
}
else
printTable(id,scores,count);
}
void printTable(int id[], int scores[], int count)
{
int i;
int oneScore;
float average;

for (int i = 0; i < MAX_SIZE; i++)
{
cout << id[i] << setw(17) << scores[i] << setw(17) << grades << endl;
}
}

//This section is whats giving me a hard time.
{
int scores[MAX_SIZE];

oneScore = 0;
while (!rss.eof() && oneScore < MAX_SIZE)
{
if (oneScore > average + 10)
{
}
else if (oneScore < average - 10)
{
}
else
{
}
oneScore++;
}
}

float computeAverage(int scores[], int count)
{
int id[MAX_SIZE];
int sum = 0;
float average;
int i;

for(int i = 0; i < MAX_SIZE; i++)
{
sum += scores[i];
count++;
}
average = sum / MAX_SIZE;
return average;
}

{
cout << "\nStudent ID" << setw(13) << "Scores" << setw(13) << "Grades"<< endl;
}

{
int tempID;
int tempScore;

//Get input
{
id[count] = tempID;
scores[count] = tempScore;
count++;

if (count > MAX_SIZE)
{
tooMany = true;
}
else
tooMany = false;
}
}

{
{
cerr << "***!!! ERROR: Cannot open file for input !!!***" << endl;
return EXIT_FAILURE;	// failure return
}
}``````

This is an example of my output
1001 89
1008 85
1024 98
1029 76
1053 0
1189 38

again, any help would be appreciated.

2
Contributors
1
2
Views
8 Years
Discussion Span
Last Post by Jiwe
``````//This section is whats giving me a hard time.
{
ifstream rss; // You are not opening the file
// You should do ifstream rss("filename.something");
int scores[MAX_SIZE];

oneScore = 0;
while (!rss.eof() && oneScore < MAX_SIZE)
{
if (oneScore > average + 10)
{
}
else if (oneScore < average - 10)
{
}
else
{