summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdullah Havaldar <[email protected]>2022-11-29 17:44:42 -0800
committerAbdullah Havaldar <[email protected]>2022-11-29 17:44:42 -0800
commitb43be2b535e830055ffff39068cb1704010342b5 (patch)
tree132fce8870c392404a41ebd16516230c02fcd9fc
parentread in file and all output (diff)
downloadcst116-lab3-abd00l4h-b43be2b535e830055ffff39068cb1704010342b5.tar.xz
cst116-lab3-abd00l4h-b43be2b535e830055ffff39068cb1704010342b5.zip
formatting output
-rw-r--r--BlankConsoleLab/CST116-Lab3-Havaldar.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/BlankConsoleLab/CST116-Lab3-Havaldar.cpp b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
index a10cac4..df214a3 100644
--- a/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
+++ b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
@@ -33,12 +33,22 @@ int main()
int totalPpl = 0;
double totalCost = 0;
- cout << "Trip" << setw(20) << "Pickup" << setw(20) << "Dropoff" << setw(20) << "#ppl" << setw(20) << "Distance" << setw(20) << "Fare" << setw(20) << "Toll" << setw(20) << "Total" << setw(20) << "Cost/Mi" << endl;
+ cout << left;
+ cout << setw(20) << "Trip"
+ << setw(20) << "Pickup"
+ << setw(20) << "Dropoff"
+ << setw(20) << "#ppl"
+ << setw(20) << "Distance"
+ << setw(20) << "Fare"
+ << setw(20) << "Toll"
+ << setw(20) << "Total"
+ << setw(20) << "Cost/Mi"
+ << endl;
while (theFile >> pick >> drop >> ppl >> dis >> fare >> toll) {
double total = fare + toll;
double cpm = total / dis;
- cout << count
+ cout << setw(20) << count
<< setw(20) << pick
<< setw(20) << drop
<< setw(20) << ppl
@@ -57,8 +67,8 @@ int main()
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
- cout << left << setw(20) << "** Avg Cost Per Person: " << avg << " **" << endl;
- cout << left << setw(20) << "** People Transported: " << totalPpl << " **" << endl;
- cout << left << setw(20) << "** Total Cost: " << totalCost << " **" << endl;
+ cout << setw(20) << "** Avg Cost Per Person: " << avg << " **" << endl;
+ cout << setw(20) << "** People Transported: " << totalPpl << " **" << endl;
+ cout << setw(20) << "** Total Cost: " << setprecision(7) << totalCost << " **" << endl;
}