diff options
| author | Joe Traver <[email protected]> | 2022-11-26 22:25:14 -0800 |
|---|---|---|
| committer | Joe Traver <[email protected]> | 2022-11-26 22:25:14 -0800 |
| commit | a5872e3d7b6e05ae8400cd067f90ff0c48d0b000 (patch) | |
| tree | 27ebc362f218a44b0be2d1812c9e8b01e0b46425 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | distance zero catch commented out (diff) | |
| download | cst116-lab3-joetraver30-a5872e3d7b6e05ae8400cd067f90ff0c48d0b000.tar.xz cst116-lab3-joetraver30-a5872e3d7b6e05ae8400cd067f90ff0c48d0b000.zip | |
Up to tutor need
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
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) |