1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <fstream>
#include <cstring>
using namespace std;
//enum
enum status { UNDERGRADUATE, GRADUATE };
//structures
struct Athlete
{
string fullName;
int* scores;
status stStatus;
int average;
int* max;
};
//function prototypes
void outputA_Struct(Athlete, int);
int minScore(int*, int);
int * maxScore(int*, int);
void changeScore(Athlete*, string, int, int, int, int);
int computeAvg(int*, int);
vector<Athlete> listOfHigherThan_X(Athlete, int, int);
vector<Athlete> listOfAll_As(Athlete, int, int);
void outputVector(vector<Athlete>);
//my functions
void showMenu();
int main()
{
//User input for file name
string fileName;
//User input for #s
int numAthletes;
int numScores;
//Read from file
string athleteL;
//Read from file
int score;
int whatClass;
//File variable
ifstream fileN;
//Structure Variable
Athlete athlete1;
//string end = ".txt";
cout << "Please enter the name of the file you wish to read from: ";
//getline(cin, fileName);
//fileName.append(end);
fileN.open("name.txt");
cout << "Please enter the number of students on the file: ";
cin >> numAthletes;
cout << "Please enter the number of scores per student: ";
cin >> numScores;
string athleteF;
fileN.open(fileName.c_str());
if (fileN.is_open())
{
cout << "yeah ok." << endl;
}
else
{
cout << "This file could not be opened." << endl;
}
while (fileN)
{
fileN >> athleteF;
cout << "READ athleteF: " << athleteF << endl;
fileN >> athleteL;
cout << "READ athleteL: " << athleteL << endl;
fileN >> whatClass;
cout << "READ whatClass: " << whatClass << endl;
if (whatClass == 0)
{
athlete1.stStatus = UNDERGRADUATE;
}
else if (whatClass == 1)
{
athlete1.stStatus = GRADUATE;
}
}
showMenu();
/*
int array2[] = { 99, 90, 95, 43 };
int minimum;
int size = 4;
minimum = minScore(array2, size);
cout << minimum;
int * maximum;
maximum = maxScore(array2, size);
*/
return 0;
}
|