Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Christian Ballard
- // COSC 1336 - 001
- // March 25th 2015
- // This program will read user input and generate a grade report.
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <ctime>
- using namespace std;
- // Five global column widths
- string studentName = "Student Name ";
- string minimum = "Min ";
- string maximum = "Max ";
- string average = "Average ";
- string grade = "Grade";
- const int NUM_GRADES = 10;
- void displayReportHeading(string fileName);
- void readStudentRecord(ifstream &fin, string &studentName, const int arrGrades[], const int numGrades);
- int main()
- {
- int grades[10];
- string studentName;
- string fileName = "COSC 1336 001 S15.txt";
- ifstream fin; // Object to read data from input file.
- ofstream fout; // Object to write results to output file.
- fin.open(fileName); // Attach the file stream to the physical file.
- if (fin.fail()) // Test for successful file opening.
- {
- cout << "\nError opening input file: " << fileName << ".\n";
- fin.close();
- system("pause");
- return EXIT_FAILURE; // Terminate program.
- }
- displayReportHeading(fileName);
- readStudentRecord(fin, studentName, grades, NUM_GRADES);
- system("pause");
- return 0;
- }
- // Displays the title line, column headings, and students records.
- void displayReportHeading(string fileName)
- {
- string::size_type recordLineLength = studentName.length() + minimum.length() + maximum.length() + average.length() + grade.length();
- string::size_type titleLength = 0;
- string title = "Grade Report for " + fileName + " - March 2015";
- string recordLine = studentName + minimum + maximum + average + grade;
- cout << right << setw((recordLineLength - titleLength) / 2 + titleLength)
- << title << endl;
- cout << right << setw((recordLineLength - titleLength) / 2 + titleLength)
- << recordLine << endl;
- for (int i = 0; i < title.length(); i++)
- {
- cout << "-";
- } cout << endl;
- }
- void readStudentRecord(ifstream &fin, string &studentName, const int arrGrades[], const int numGrades)
- {
- int pos1, pos2;
- getline(fin, studentName, '\t');
- for (int i = 0; i < 11; i++)
- {
- /*fin >> arrGrades[i];*/
- //getline(fin, arrGrades[i], '\t');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment