1-d arrays score analysis program

I have most of the code i need written...i think. I am having trouble making it all come together and work fluidly. I want the menu to output and then the user inputs a menu number. I want that task to be performed and then return to the menu. I also need the scores.txt file to be used in the cases where the user does not enter them first, as a default. I also need to make sure the numbers entered are passed by every function. thank you.

#include <iostream>
#include <fstream>
using namespace std;

void getNumbers();
void numFromFile();
void printAll();
void printHigh();
void printLow();
void printAvg();
void printOneScore();

int main()
{

int scores[10];
int menu;

cout << "-------------------------------------------------" << endl;
cout << "1-D ARRAY PROCESSING MENU OPTIONS" << endl;
cout << "-------------------------------------------------" << endl;
cout << endl;
cout << "1. Read in 10 scores from user."<< endl;
cout << "2. Read in 10 scores from the file, scores.txt." << endl;
cout << "3. Print all scores." << endl;
cout << "4. Print the highest score." << endl;
cout << "5. Print the lowest score." << endl;
cout << "6. Print the average score." << endl;
cout << "7. Print one score (give its entry number)." << endl;
cout << "8. quit program." << endl;
cout << endl;
cout << "Enter your choice: " ;
cin >> menu;

switch (menu)
{
case 1: getNumbers();
break;

case 2: numFromFile();
break;

case 3: printAll();
break;

case 4: printHigh();
break;

case 5: printLow();
break;

case 6: printAvg();

break;

case 7: printOneScore();
break;

case 8: return 0;
break;

default: cout << "Invalid entry. Please pick an appropriate menu number.";
break;
return 0;

}

return 1;
}
void getNumbers()
{
const int numScores =10;
int scores[numScores];
int count;
for (count =1; count <= numScores; count++)
{
cout << "Enter score #" << count << ": " ;
cin >> scores [count];
}

}


void numFromFile()
{
ifstream inFile;
inFile.open("scores.txt");
int n;
if (!inFile)
{
cout << "File error." << endl;

}
else
{
inFile>> n;
for(int i = 1; i <= 10; i++)
{
scores[n];
}

}

inFile.close();
return 0;
}

void printAll()
{
int count, numScores;
int scores[numScores];
for (count =1; count <=numScores; count++)
{
cout << "Score #" << count << ": ";
cout << scores [count];
}
}

void printHigh()
{

int highest;
highest = scores[9];
for (int h=1; h<=10; h++)
{
if (highest < scores[h])
{
highest = scores[h];
}

}
}

void printLow()
{
int low= scores[0];
for (int s=1; s<=10; s++)
{
if (low> scores[s])
{
low =scores[s];
}

}
}

void printAvg()
{
int sum=0;

for (count =1; count <=numScores; count ++)
{
sum = sum + scores[count];

}
cout "The average score is " << sum/10 << "." << endl;

}

void printOneScore()
{
int number,n;
cout << "What score do you want to print? ";
cin >> number;
number=n;
cout << scores[n];

}
Topic archived. No new replies allowed.