summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorBirducken <[email protected]>2022-11-29 13:16:05 -0800
committerBirducken <[email protected]>2022-11-29 13:16:05 -0800
commit36c5308958c9bfe2d32028daa6d10db71c45db55 (patch)
tree2dca4ad3def9757276e150be6d176c71debf9fba /BlankConsoleLab
parentFinished calculations. (diff)
downloadarchived-cst116-lab3-stark-36c5308958c9bfe2d32028daa6d10db71c45db55.tar.xz
archived-cst116-lab3-stark-36c5308958c9bfe2d32028daa6d10db71c45db55.zip
Added summary.
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/cst116-lab3-stark.cpp19
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;
}