cout << "(1) Select / create data file (.txt file extention will be added automaticly)" << endl;
cout << "(2) Display all numbers, total and average" << endl;
cout << "(3) Display all numbers sorted" << endl;
cout << "(4) search for a number and display how many times it occurs" << endl;
cout << "(5) display the largest number" << endl;
cout << "(6) Append a random number(s)" << endl;
cout << "(7) Exit the program" << endl << endl;
void displayNumTotalAverage(string FileName)
{
ifstream inFile;
cout << "Display Number Total Average - Option 2" << endl << endl << endl;
inFile.open("C:\\Users\Wizard\Libraries\Documents\Final Project" + FileName + ".txt");
int num;
int total;
cout << "Display Number Total Average function" << FileName;
double average;
bool containsNum = false;
inFile.open(FileName + ".txt");
if (inFile)
{
while (inFile >> num)
{
cout << num << endl;
}
inFile.close();
}
else
{
cout << "Error opening file" << FileName << "." << endl;
}
system("PAUSE");
return;
}
void displaySortedNums()
{
cout << "I AM THE displaySortedNums Function - Option 3" << endl;
{
int i, j, flag = 1; // set flag to 1 to start first pass
int temp; // holding variable
int numLength = num.length();
for (i = 1; (i <= numLength) && flag; i++)
{
flag = 0;
for (j = 0; j < (numLength - 1); j++)
{
if (num[j + 1] > num[j]) // ascending order simply changes to <
{
temp = num[j]; // swap elements
num[j] = num[j + 1];
num[j + 1] = temp;
flag = 1; // indicates that a swap occurred.
}
}
}
return; //arrays are passed to functions by address; nothing is returned
}
system("PAUSE");
return;
}
void searchNum()
{
int search;
cout << " I am the searchNum function - option 4" << endl;
cout << "Search Number: ";
cin >> search;
system("PAUSE");
return;
}
void displayLargestNum()
{
cout << "I am the displayLargestNum Function - option 5" << endl;
system("PAUSE");
return;
}
void appendRandomNum(string FileName)
{
cout << "i am in the appendRandomNum function - option 6" << endl;
int num = 0;
int count = 0;
ofstream outFile;
outFile.open(FileName + ".txt", ios::app);
cout << "How many random numbers: ";
cin >> count;
for (int i = 0; i < count; i++)
outFile << rand() % 10 << endl;
outFile.close();
cout << endl << "Number(s) Added" << endl << endl;
system("PAUSE");
return;
}
void exit()
{
cout << " I am the exit function - option 7" << endl;
system("PAUSE");
return;
}
void CreateFile()<---Creates Random Gen/ Array
{
int random[50]; //Random Numbers