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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
#include <iostream>
#include <fstream>
#include <string>
#include<iomanip>
using namespace std;
int n; //n = number of students
const int NUMBER_OF_nonNumerical = 9;
const int NUMBER_OF_COURSES = 3;
const int NUMBER_OF_SCORES = 6;
const int THREE = 3;
const int TWO =2;
string student_nonNumeric1[3][NUMBER_OF_nonNumerical]; //store student string information
int student_numeric1 [THREE][TWO]; // store student age and years at Texas State
double courses_Numeric2 [3][NUMBER_OF_COURSES][NUMBER_OF_SCORES]; // store three students, three courses and five exams/computed average
char letterGrade [THREE][NUMBER_OF_COURSES]; // store letter grade of three students and three courses
//function prototypes
void inputData(int n, string student_nonNumeric1[n][NUMBER_OF_nonNumerical],
int student_numeric1 [THREE][TWO],
int courses_Numeric2 [n][NUMBER_OF_COURSES][NUMBER_OF_SCORES]);
void validateData(double);
void NumGrade(double);
void LetGrade(char);
void Comments(char);
void Reports(char);
int main()
{
//number of students
cout << "Enter how many students do you want to see:" << endl;
cin >> n;
// Validate the input while loop
while ( n < 3 || n > 100 )
{
cout << "You should have at least 3 students" << endl;
//get number of students again
cout << "Enter how many students do you want to see:";
cin >> n;
}
//Open Input and Output file
/* ifstream fin;
fin.open("project5_A04889172_Input.txt");
if (!fin)
{
cout << "cant open1" << endl;
}
ofstream fout;
fout.open("project5_A04889172_Output.txt");
if (!fout)
{
cout << "cant open" << endl;
}
*/
inputData(n, student_nonNumeric1,
student_numeric1,courses_Numeric2);
//validateData(courses_Numeric2);
//NumGrade(student_numeric1, courses_Numeric2);
//LetGrade();
//Comments();
//Reports(student_numeric1);
}
void inputData(int n, string student_nonNumeric1[n][NUMBER_OF_nonNumerical],
int student_numeric1 [THREE][TWO], int courses_Numeric2 [n][NUMBER_OF_COURSES][NUMBER_OF_SCORES])
{
//Open Input and Output file
ifstream fin;
fin.open("project5_A04889172_Input.txt");
if (!fin)
{
cout << "cant open1" << endl;
}
ofstream fout;
fout.open("project5_A04889172_Output.txt");
if (!fout)
{
cout << "cant open" << endl;
}
for (int i = 0; i < n; i++)
{
getline(fin, student_nonNumeric1[i][0]); //header;
getline(fin, student_nonNumeric1[i][1]); //name
cout << student_nonNumeric1[i][1];
getline(fin, student_nonNumeric1[i][2]); // Id number
getline(fin, student_nonNumeric1[i][3]); //address
getline(fin, student_nonNumeric1[i][4]); //phone number
getline(fin, student_nonNumeric1[i][5]); //social security
fin >> student_numeric1[i][0]; // age
fin >> student_numeric1[i][1]; //years at texas state
fin.ignore();
for (int j = 0; j < NUMBER_OF_COURSES; j++)
{
getline(fin, student_nonNumeric1[i][i]);
for (int k = 0; k < NUMBER_OF_SCORES; k++)
{
fin >> courses_Numeric2[i][j][k];
}
}
}
}
void validateData(int student_numeric1 [THREE][TWO], int n, string student_nonNumeric1[n][NUMBER_OF_nonNumerical])
{
}
void validateData(int n, double )
{
}
void NumGrade()
{
}
void LetGrade()
{
}
void Comments()
{
}
void Reports()
{
}
|