diff options
| author | Birducken <[email protected]> | 2022-11-29 13:16:05 -0800 |
|---|---|---|
| committer | Birducken <[email protected]> | 2022-11-29 13:16:05 -0800 |
| commit | 36c5308958c9bfe2d32028daa6d10db71c45db55 (patch) | |
| tree | 2dca4ad3def9757276e150be6d176c71debf9fba | |
| parent | Finished calculations. (diff) | |
| download | archived-cst116-lab3-stark-36c5308958c9bfe2d32028daa6d10db71c45db55.tar.xz archived-cst116-lab3-stark-36c5308958c9bfe2d32028daa6d10db71c45db55.zip | |
Added summary.
| -rw-r--r-- | BlankConsoleLab/cst116-lab3-stark.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/BlankConsoleLab/cst116-lab3-stark.cpp b/BlankConsoleLab/cst116-lab3-stark.cpp index bb8b50b..e072d68 100644 --- a/BlankConsoleLab/cst116-lab3-stark.cpp +++ b/BlankConsoleLab/cst116-lab3-stark.cpp @@ -15,6 +15,7 @@ using std::fixed; const int width = 10; void readFile(ifstream& fin, double fares[], int& totalPass); +void summary(double fares[], int& totalPass); int main() { ifstream fin; @@ -34,8 +35,9 @@ int main() { cout << setw(width) << "Pick:" << setw(width) << "Drop:" << setw(width) << "Pass #:" << setw(width) << "Dist:" << setw(width) << "Fare:" << setw(width) << "Toll:" << setw(width) << "Total:" << setw(width) << "Cost/Mi:" << endl; readFile(fin, fares, totalPass); - + summary(fares, totalPass); } + void readFile(ifstream& fin, double fares[], int& totalPass) { int i = 0; int pick, drop, pass; @@ -55,5 +57,20 @@ void readFile(ifstream& fin, double fares[], int& totalPass) { totalPass += pass; fares[i] = total; + i++; + } + cout << endl; +} + +void summary(double fares[], int& totalPass) { + float totalPaid = 0, average; + int i; + for (i = 0; i < 50; i++) { + totalPaid += fares[i]; } + average = totalPaid / totalPass; + + cout << "Total Passangers: " << totalPass << endl; + cout << "Total Fares: " << totalPaid << endl; + cout << "Mean fare per passanger: " << average << endl; } |