summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp17
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"