summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Rogers <[email protected]>2022-11-28 13:58:19 -0800
committerTaylor Rogers <[email protected]>2022-11-28 13:58:19 -0800
commit7baec85787550efe3b22218a618317763ff8a0b8 (patch)
tree1e897c52102060f0e50b91a2ad5f500595b79fd9
parentadded name (diff)
downloadcst116-lab3-taylorrog-7baec85787550efe3b22218a618317763ff8a0b8.tar.xz
cst116-lab3-taylorrog-7baec85787550efe3b22218a618317763ff8a0b8.zip
Added output file headers
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp16
-rw-r--r--BlankConsoleLab/lab3_Report.txt4
-rw-r--r--BlankConsoleLab/lab3_data.txt2
3 files changed, 14 insertions, 8 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ad4a7ad..6e94674 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -6,6 +6,7 @@
#include <iostream>
#include <fstream>
#include <iomanip>
+#include <string>
using std::cout;
@@ -17,7 +18,7 @@ using std::ifstream;
using std::ofstream;
using std::string;
-const int MAX = 100;
+const int MAX = 50;
int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[]);
@@ -26,6 +27,8 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa
void PrintTotalsAndSummary(ofstream& out, int totalRecords);
+
+
int main()
{
@@ -36,12 +39,12 @@ int main()
float fare[MAX];
float toll[MAX];
int record_counter(0);
- string filename;
-
+
+ string fnameinput;
// Filename from user input
cout << "Enter the file name you wish to read data from: ";
- cin >> filename;
+ cin >> fnameinput;
cout << endl;
ifstream inFile;
@@ -49,7 +52,7 @@ int main()
// Notice how this automatically opens the file
ofstream outFile("lab3_Report.txt");
- inFile.open(filename);
+ inFile.open(fnameinput);
if (inFile.is_open())
{
@@ -105,6 +108,9 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa
int counter)
{
outFile << " Here is the Output File" << endl;
+ outFile << endl;
+ outFile << setw(5) << "Pickup" << setw(10) << "Dropoff" << setw(12) << "Passengers" << setw(14) << "Distance" << setw(14) << "Fare" << setw(14) << "Toll" << endl;
+
for (int r = 0; r <= counter - 1; r++)
{
outFile << setiosflags(ios::left)
diff --git a/BlankConsoleLab/lab3_Report.txt b/BlankConsoleLab/lab3_Report.txt
index 1b24b39..2a620e9 100644
--- a/BlankConsoleLab/lab3_Report.txt
+++ b/BlankConsoleLab/lab3_Report.txt
@@ -1,11 +1,11 @@
Here is the Output File
+Pickup Dropoff Passengers Distance Fare Toll
129 7 3 1.3 7.5 0
36 69 1 11.41 32 5.76
7 41 1 4.6 15 5.76
150 61 2 6.75 23 0
112 17 1 3.84 15 0
-80 112 6 1.64 9.5 0
- ** Total Records: 6 **
+ ** Total Records: 5 **
The End
diff --git a/BlankConsoleLab/lab3_data.txt b/BlankConsoleLab/lab3_data.txt
index 18f3c16..28a3ae6 100644
--- a/BlankConsoleLab/lab3_data.txt
+++ b/BlankConsoleLab/lab3_data.txt
@@ -3,4 +3,4 @@
7 41 1 4.6 15 5.76
150 61 2 6.75 23 0
112 17 1 3.84 15 0
-80 112 6 1.64 9.5 0
+80 112 6 1.64 9.5 0 \ No newline at end of file