summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 75cb3c2..9703a9e 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -42,29 +42,28 @@ int ReadData(ifstream& file) {
}
+ t++;
+
return t;
}
void GenerateTotals(int numEntries) {
- for (int i = 0; i < numEntries; i++) {
- cout << "Total fare for entry " << i + 1 << ": $" << totalFare[i] << endl;
- }
-
int totalPassengers = 0;
double totalPaid = 0;
- for (int i = 0; i < numEntries; i++) {
+ for (int i = 0; i <= numEntries; i++) {
totalPassengers += passengerCount[i];
totalPaid += totalFare[i];
}
- cout << "A total of " << totalPassengers << " passengers were transported." << endl;
- cout << "Altogether, the total amount paid was $" << totalPaid << endl;
- cout << "The average cost per person was $" << totalPaid / totalPassengers << endl;
+ cout << "TOTAL PASSENGERS: " << totalPassengers << endl;
+ cout << "TOTAL PAID: $" << totalPaid << endl;
+ cout << "COST PER PERSON: $" << totalPaid / totalPassengers << endl;
+ cout << "TOTAL TRIPS: " << numEntries << endl;
}
@@ -90,11 +89,24 @@ int main()
int numEntries = ReadData(inFile);
- cout << "\nFound " << numEntries << " entries" << endl;
-
GenerateTotals(numEntries);
-
+
+ cout << left << setw(15) << "PICKUP ST."
+ << setw(15) << "DROPOFF ST." << setw(15) << "# PASSENGERS"
+ << setw(15) << "DISTANCE" << setw(15) << "FARE"
+ << setw(15) << "TOLL" << setw(15) << "TOTAL"
+ << setw(15) << "$/MILE" << endl;
+
+ for (int i = 0; i < numEntries; i++) {
+
+ cout << left << setw(15) << pickUp[i]
+ << setw(15) << dropOff[i] << setw(15) << passengerCount[i]
+ << setw(15) << distanceTravelled[i] << setw(15) << fareAmount[i]
+ << setw(15) << tollAmount[i] << setw(15) << totalFare[i]
+ << setw(15) << costPerMile[i] << endl;
+
+ }
}