diff options
| author | Taylor Rogers <[email protected]> | 2022-11-28 14:53:13 -0800 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-11-28 14:53:13 -0800 |
| commit | 2c2a20fbee572f875f33eb545b71cf94808d71e3 (patch) | |
| tree | fb077fd0f833d8f40e5250c37371088380c72152 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | Added passenger and cost total (diff) | |
| download | cst116-lab3-taylorrog-2c2a20fbee572f875f33eb545b71cf94808d71e3.tar.xz cst116-lab3-taylorrog-2c2a20fbee572f875f33eb545b71cf94808d71e3.zip | |
Added average cost
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index dbd583c..6c331be 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -143,12 +143,17 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int totalPassengers, float totalSum) { + float avgcost = 0; + avgcost = totalSum / totalPassengers; // To screen cout << "Total Records: " << totalRecords << "." << endl; cout << "Total Passengers: " << totalPassengers << "." << endl; cout << "Total Cost: " << totalSum << "." << endl; + cout << "Average Cost: " << avgcost << "." << endl; // To file - outFile << "\n\n\t** Total Records: " << totalRecords << " **\n" - << "\t\t The End \n"; + outFile << "Total Records: " << totalRecords << "." << endl; + outFile << "Total Passengers: " << totalPassengers << "." << endl; + outFile << "Total Cost: " << totalSum << "." << endl; + outFile << "Average Cost: " << avgcost << "." << endl; } |