From a5872e3d7b6e05ae8400cd067f90ff0c48d0b000 Mon Sep 17 00:00:00 2001 From: Joe Traver Date: Sat, 26 Nov 2022 22:25:14 -0800 Subject: Up to tutor need --- BlankConsoleLab/BlankConsoleLab.cpp | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'BlankConsoleLab/BlankConsoleLab.cpp') diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index ae848af..434d943 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -24,6 +24,8 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa int counter); void PrintTotalsAndSummary(ofstream& outFile, int totalRecords); void PassengerCount(int psgr[], int counter, int pplt); +void TotalPaid(int tfare[], int counter, int paid); +void AverageCostPerPerson(int paid, int pplt, int ACM); int main() { @@ -34,6 +36,7 @@ int main() float dist[MAX]; float fare[MAX]; float toll[MAX]; + int counter = 0; float tfare[MAX]; float CPM[MAX]; int pplt = 0; @@ -55,6 +58,9 @@ int main() if (outFile.is_open()) { WriteOutputFile(outFile, pick, drop, psgr, dist, fare, toll, record_counter); + PassengerCount(psgr, counter, pplt); + TotalPaid(tfare, counter, paid); //dont know exactly whats happening here + AverageCostPerPerson(paid, pplt, paid); PrintTotalsAndSummary(outFile, record_counter); outFile.close(); } @@ -94,7 +100,7 @@ int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], { tfare[counter] = fare[counter] + toll[counter]; - CPM[counter] = fare[counter] / dist[counter]; + CPM[counter] = fare[counter] / dist[counter]; //can't get the check to work //if (dist[counter] = 0) //CPM[counter] = 0; @@ -131,14 +137,42 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa << endl; } } -void PassengerCount(int psgr[], int counter, int pplt) +void PassengerCount(int psgr[], int counter, int pplt) // counter isnt being brought in { for (int i = 0; i <= counter; i++) { pplt = pplt + psgr[i]; + i++; + + } + + cout << endl << "Total number of passengers transported: " << pplt << endl; + +} + +void TotalPaid(int tfare[], int counter, int paid) // counter isnt being brought in +{ + + for (int i = 0; i <= counter; i++) + { + paid = paid + tfare[i]; + i++; } + + cout << "Total fairs paid: " << paid << endl; + +} + +void AverageCostPerPerson(int paid, int pplt, int ACM) +{ + + ACM = paid / pplt; + + + cout << "Average cost per person: " << ACM << endl; + } void PrintTotalsAndSummary(ofstream& outFile, int totalRecords) -- cgit v1.2.3