diff options
| author | tafaar <[email protected]> | 2022-11-28 20:23:31 -0800 |
|---|---|---|
| committer | tafaar <[email protected]> | 2022-11-28 20:23:31 -0800 |
| commit | 775c204baf820d1b9c9e2013b8ffc8b10fec31f3 (patch) | |
| tree | 2facbb3ffd1a3cecda9febf00d64c209860d51fa | |
| parent | added functions (diff) | |
| download | cst116-lab3-hill-775c204baf820d1b9c9e2013b8ffc8b10fec31f3.tar.xz cst116-lab3-hill-775c204baf820d1b9c9e2013b8ffc8b10fec31f3.zip | |
tweaked logic
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 34 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj | 1 | ||||
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.vcxproj.filters | 3 | ||||
| -rw-r--r-- | BlankConsoleLab/big.txt | 48 | ||||
| -rw-r--r-- | BlankConsoleLab/small.txt | 2 |
5 files changed, 76 insertions, 12 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; + + } } diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj index dfe725d..ac9affa 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj @@ -142,6 +142,7 @@ <ClCompile Include="BlankConsoleLab.cpp" /> </ItemGroup> <ItemGroup> + <Text Include="big.txt" /> <Text Include="small.txt" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters index cfb09a9..2ae2465 100644 --- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters +++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters @@ -23,5 +23,8 @@ <Text Include="small.txt"> <Filter>Source Files</Filter> </Text> + <Text Include="big.txt"> + <Filter>Source Files</Filter> + </Text> </ItemGroup> </Project>
\ No newline at end of file diff --git a/BlankConsoleLab/big.txt b/BlankConsoleLab/big.txt new file mode 100644 index 0000000..d9fa1b1 --- /dev/null +++ b/BlankConsoleLab/big.txt @@ -0,0 +1,48 @@ +129 7 3 1.3 7.5 0 +36 69 1 11.41 32 5.76 +7 41 1 4.6 15 5.76 +150 61 2 6.75 23 0 +112 17 1 3.84 15 0 +80 112 6 1.64 9.5 0 +256 183 1 16.08 44.5 0 +138 166 2 7.4 24.5 6.12 +142 50 5 1.7 8 0 +107 163 0 3.6 17 0 +132 3 2 19.1 52 6.12 +48 41 1 4.07 18 4.36 +132 226 1 14.3 39 0 +229 151 1 3.96 14.5 4.58 +238 166 1 0.76 4.5 0 +151 238 2 0.64 5 2.2 +138 82 4 3 12 0 +264 231 3 10.74 32.5 0 +170 114 5 2.01 9 0 +186 87 2 3.45 12 0 +209 256 1 3.79 17 0 +132 107 1 17.2 52 6.12 +232 112 1 3.1 11 0 +164 141 3 2.85 10.5 0 +129 7 3 1.3 7.5 0 +36 69 1 11.41 32 5.76 +7 41 1 4.6 15 5.76 +150 61 2 6.75 23 0 +112 17 1 3.84 15 0 +80 112 6 1.64 9.5 0 +256 183 1 16.08 44.5 0 +138 166 2 7.4 24.5 6.12 +142 50 5 1.7 8 0 +107 163 0 3.6 17 0 +132 3 2 19.1 52 6.12 +48 41 1 4.07 18 4.36 +132 226 1 14.3 39 0 +229 151 1 3.96 14.5 4.58 +238 166 1 0.76 4.5 0 +151 238 2 0.64 5 2.2 +138 82 4 3 12 0 +264 231 3 10.74 32.5 0 +170 114 5 2.01 9 0 +186 87 2 3.45 12 0 +209 256 1 3.79 17 0 +132 107 1 17.2 52 6.12 +232 112 1 3.1 11 0 +164 141 3 2.85 10.5 0
\ No newline at end of file diff --git a/BlankConsoleLab/small.txt b/BlankConsoleLab/small.txt index 3d94536..f9423ec 100644 --- a/BlankConsoleLab/small.txt +++ b/BlankConsoleLab/small.txt @@ -8,4 +8,4 @@ 112 17 1 3.84 15 0 -80 112 6 1.64 9.5 0
\ No newline at end of file +80 112 6 1.64 9.5 0
\ No newline at end of file |