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
|
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
// Function declarations
void gradeResult(ifstream& in_file, ofstream& out_file, int labPercent, int examPercent, int
hwPercent, int projPercent);
double average(int Scores[], int size);
char grade(double final_score);
void highest_scorer(double total, double& total_High, string name, string& High_name);
void lowest_scorer(double total, double& total_Low, string name, string& Low_name);
int main()
{
ofstream out_file;
ifstream in_file;
in_file.open("Score.txt"); // opens file
out_file.open("EECS138score.txt"); // opens file
if (in_file.fail()) // if file is not found, this will be displayed
{
cout << "Failed to open file." << endl;
exit(1);
}
string filename;
cout << "Please enter the name of your output file:" << endl;
cin >> filename;
gradeResult(in_file, out_file, 15, 40, 25, 20);
cout << "Reading from input files." << endl;
cout << "Your output file has been created and the computation results have been stored there." << endl;
}
// Function definitions
void gradeResult(ifstream& in_file, ofstream& out_file, int labPercent, int examPercent, int
hwPercent, int projPercent)
{
while(!in_file.eof())
{
string name;
in_file >> name;
int lab[5];
in_file >> lab[0];
in_file >> lab[1];
in_file >> lab[2];
in_file >> lab[3];
in_file >> lab[4];
int exam[2];
in_file >> exam[5];
in_file >> exam[6];
int homework[3];
in_file >> homework[7];
in_file >> homework[8];
in_file >> homework[9];
int project[1];
in_file >> project[10];
}
}
/*double average(int Scores[], int size)
{
}
char grade(double final_score)
{
}
void highest_scorer(double total, double& total_High, string name, string& High_name)
{
}
void lowest_scorer(double total, double& total_Low, string name, string& Low_name)
{
}
*/
|