-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputHandler.cpp
More file actions
39 lines (33 loc) · 894 Bytes
/
OutputHandler.cpp
File metadata and controls
39 lines (33 loc) · 894 Bytes
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
#include "OutputHandler.h"
#include "Course.h"
#include "Student.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
void printAllStudentsToFile(
const StudentList& studentList, double tuitionRate)
{
//Declare stream object
std::ofstream outfile;
//Ask user how to name the file to write to
std::string nameOfFile;
std::cout << "Enter a name for a new file to write on "
<< "(include extension.txt) : \n";
std::cin >> nameOfFile;
outfile.open(nameOfFile);
if (outfile.fail())
{
std::cerr << "Output file opening failed.\n";
//system("Pause");
//exit(1);
}
else
{
outfile
<< "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n"
<< " UNOFFICIAL TRANSCRIPTS\n"
<< "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-\n\n";
studentList.printStudentsToFile(outfile, tuitionRate);
}
}