file input/output

so, I am trying to write a program that it reads a list of numbers from a file output the numbers and get average, max, min and scores higher than average I have not idea what to do or how to approach I need to use all the prototypes that I already have in my program

//libraries
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;


int numberOfScores(string f); //count the number of scores in the input file

void inputScores(int* a, int n, string f); //input scores from a user selected input file

double avgScore(int* a, int n); //calculate the average score

int scoresGreaterAverage(int* a, int n, double avg); //calculate number of scores greater than average score

int highScore(int* a, int n); //find highest score

int lowScore(int* a, int n); //find lowest score

//main program
int main()
{

//variables/data
string fileName; //name of input file from the user
int count=0; //number of scores in the input file
int *scores;//scores (array) = store scores read from input file
int maxScore=0; //highest score of all the scores from the input file
int minScore=0; //lowest score of all the scores from the input file
int totalScores=0; //sum of all the scores from the input file
double averageScore; //average score of all the scores from the input file (formatted to 1 digit past decimal point)
int nGreater; //number of scores greater than the average score from all the scores in the input file
string line; //whatever is on each line of the input file
int i=0; // loop index
ifstream file; //file stream object
//get the file name
cout <<"What is the input file name? [filename.txt]: ";
cin >> fileName;
inputScores(scores, i, fileName);
file.open(fileName.c_str(), ios::in);
if (file)
{
getline(file, line);
//read an item from file
while(file)
{
//read the next item.

getline(file, line);
count++;
}
//close the file.
file.close();
cout << "The number of scores from file " << fileName<< " are: " << count<<endl;
}
else
{
cout << "Error: cannot open file.\n";
}

inputScores(scores, i, fileName);
for (i=0; i<count; i++)




return 0;

}//main

//count the number of scores in the input file
int numberOfScores(string f)
{
//variables
int x; //number of scores in the input file
return x;
}//numberOfScores

//input scores from a user selected input file
void inputScores(int* a, int n, string f)
{

ifstream file;
file.open(f.c_str());
{
if(file)
{
getline(file, line);
//read an item from file
while(file)
{
//read the next item.
getline(file, line);
}
cout<< "the scores are " << a[n] <<endl;
}
}
}//inputScores

//calculate the average score
double avgScore(int* a, int n)
{
//variable
double avg; //average score


return avg;
}//avgScore

//calculate number of scores greater than average score
int scoresGreaterAverage(int* a, int n, double avg)
{
//variable
int nGA; //number of scores greater than average

return nGA;
}//scoresGreaterAverage

int highScore(int* a, int n); //find highest score

int lowScore(int* a, int n); //find lowest score

Well, first you need to make a plan - like this.

1. Get the name of the input file.

2. Open the file and get the count of numbers

3. Create the array to store the input.

4. Read all the numbers into the array

5. Calculate the average

6. Find the minimum

7. Find the maximum.

8. Find all the scores higher than average.

9. Output the results

Steps 5 - 8 can be done in any order.

IMHO it's important to understand first the problem and get an idea how to solve it before writing or copying code.
yeah I figured that thanks for your help. I've been doing codeblock by codeblock and I am half way
now I am having trouble with the code to get the scores which I have as follow.

in main I declare it this way

inputScores(scores, i, fileName);
for (i=0; i< count; i++)
//and then I wrote the next code


void inputScores(int* a, int n, string f)
{
int c = 0;
string line2;
ifstream file; //file stream object
file.open(f.c_str());
for (c = 0; c < n; c++)
{
a[c] = atoi(f.c_str());
cout << a[c];
}
//close the file.
file.close();
}
Topic archived. No new replies allowed.