diff options
| author | Taylor Rogers <[email protected]> | 2022-11-28 14:48:30 -0800 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-11-28 14:48:30 -0800 |
| commit | 5bfb03d7e806552ac7095dee6f78f28a0eebb2e3 (patch) | |
| tree | 538ff3694343bbabee3914ef5ee073ba19c999ea /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | Added total and cost per mile output column (diff) | |
| download | cst116-lab3-taylorrog-5bfb03d7e806552ac7095dee6f78f28a0eebb2e3.tar.xz cst116-lab3-taylorrog-5bfb03d7e806552ac7095dee6f78f28a0eebb2e3.zip | |
Added passenger and cost total
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 17c70f9..dbd583c 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -23,9 +23,10 @@ int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], float total[], float cmp[], int counter); -void PrintTotalsAndSummary(ofstream& out, int totalRecords); - +void PrintTotalsAndSummary(ofstream& out, int totalRecords, int totalPassengers, float totalSum); +int psgrsum = 0; +float totalsum = 0; int main() @@ -62,7 +63,7 @@ int main() if (outFile.is_open()) { WriteOutputFile(outFile, pick, drop, psgr, dist, fare, toll, total, cpm, record_counter); - PrintTotalsAndSummary(outFile, record_counter); + PrintTotalsAndSummary(outFile, record_counter, psgrsum, totalsum); outFile.close(); } else @@ -123,6 +124,9 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa total[r] = fare[r] + toll[r]; cpm[r] = total[r] / dist[r]; + psgrsum += psgr[r]; + totalsum += total[r]; + outFile << setiosflags(ios::left) << setw(5) << pick[r] << resetiosflags(ios::left) << setw(10) << drop[r] << resetiosflags(ios::left) @@ -137,11 +141,12 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa } -void PrintTotalsAndSummary(ofstream& outFile, int totalRecords) +void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int totalPassengers, float totalSum) { // To screen - cout << "\n\n\t** Total Records: " << totalRecords << " **\n" - << "\t\t The End \n"; + cout << "Total Records: " << totalRecords << "." << endl; + cout << "Total Passengers: " << totalPassengers << "." << endl; + cout << "Total Cost: " << totalSum << "." << endl; // To file outFile << "\n\n\t** Total Records: " << totalRecords << " **\n" |