diff options
| author | Abdullah Havaldar <[email protected]> | 2022-11-29 17:44:42 -0800 |
|---|---|---|
| committer | Abdullah Havaldar <[email protected]> | 2022-11-29 17:44:42 -0800 |
| commit | b43be2b535e830055ffff39068cb1704010342b5 (patch) | |
| tree | 132fce8870c392404a41ebd16516230c02fcd9fc | |
| parent | read in file and all output (diff) | |
| download | cst116-lab3-abd00l4h-b43be2b535e830055ffff39068cb1704010342b5.tar.xz cst116-lab3-abd00l4h-b43be2b535e830055ffff39068cb1704010342b5.zip | |
formatting output
| -rw-r--r-- | BlankConsoleLab/CST116-Lab3-Havaldar.cpp | 20 |
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; } |