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
|
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int MAX_UNI = 1000;
void getData(string uniName[MAX_UNI], string state[MAX_UNI], string city[MAX_UNI],
int tuition[MAX_UNI], int enrollment[MAX_UNI],
double aveFreshRetention[MAX_UNI], double percentOfStudent[MAX_UNI]);
int sortArray();
int main()
{
string uniName[MAX_UNI];
string state[MAX_UNI];
string city[MAX_UNI];
int tuition[MAX_UNI];
int enrollment[MAX_UNI];
double aveFreshRetention[MAX_UNI];
double percentOfStudent[MAX_UNI];
getData(uniName, state, city, tuition, enrollment, aveFreshRetention, percentOfStudent);
return 0;
}
void getData(string uniName[MAX_UNI], string state[MAX_UNI], string city[MAX_UNI],
int tuition[MAX_UNI], int enrollment[MAX_UNI],
double aveFreshRetention[MAX_UNI], double percentOfStudent[MAX_UNI])
{
char rand;
ifstream infile;
infile.open("universities.txt");
if(infile.fail())
{
cout << "File is corrupted\n";
}
infile >> rand;
for(int i = 0; i < MAX_UNI; i++)
{
infile.ignore();
getline(infile, uniName[i]);
infile >> state[i];
infile.ignore();
getline(infile, city[i]);
infile >> tuition[i];
infile >> enrollment[i];
infile >> aveFreshRetention[i];
infile >> percentOfStudent[i];
}
cout << rand << endl;
for(int i = 0; i < 2; i++)
{
cout << "University: " << uniName[i] << endl;
cout << "State: " << state[i] << " \n";
cout << "City: " << city[i] << endl;
cout << "Tuition: " << tuition[i] << " \n";
cout << "Enrollment: " << enrollment[i] << " \n";
cout << "Average Freshman Retention: " << aveFreshRetention[i] << endl;
cout << "Percentage of Student Graduated: " << percentOfStudent[i] << endl << endl;
}
}
|