diff options
| author | jacobdw22 <[email protected]> | 2022-11-29 17:10:50 -0800 |
|---|---|---|
| committer | jacobdw22 <[email protected]> | 2022-11-29 17:10:50 -0800 |
| commit | ae3d7d19ca396ef86de01d0edb47ea623976d56a (patch) | |
| tree | 7819dce6e68c9f1aa4e728e5536559c12e508a17 | |
| parent | Adjusted starting comments (diff) | |
| download | cst116-lab3-jacobdw22-ae3d7d19ca396ef86de01d0edb47ea623976d56a.tar.xz cst116-lab3-jacobdw22-ae3d7d19ca396ef86de01d0edb47ea623976d56a.zip | |
Allows for the Total Paid to be a floating point number rather than an int, so the value acquired is more accurate.
| -rw-r--r-- | BlankConsoleLab/cst116-lab3-wilson.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/BlankConsoleLab/cst116-lab3-wilson.cpp b/BlankConsoleLab/cst116-lab3-wilson.cpp index 635c5a4..c6e97b7 100644 --- a/BlankConsoleLab/cst116-lab3-wilson.cpp +++ b/BlankConsoleLab/cst116-lab3-wilson.cpp @@ -33,7 +33,7 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int void PrintTotalsAndSummary(ofstream& out, int totalRecords, int psgr[], int num_psgr, float fare[], float toll[], float total_fare); //Defines function that prints total records to screen and output file int NumPsgr(int psgr[], int num_psgr, int totalRecords); //Defines function that calculates the number of passengers total -int TotalPaid(float fare[], float toll[], float total_fare, int totalRecords); //Defines function that calculates the total paid +float TotalPaid(float fare[], float toll[], float total_fare, int totalRecords); //Defines function that calculates the total paid ///////////////////////////// Main Function ///////////////////////////// @@ -191,7 +191,7 @@ int NumPsgr(int psgr[], int num_psgr, int totalRecords) ///////////////////////////// Total Paid Function ///////////////////////////// -int TotalPaid(float fare[], float toll[], float total_fare, int totalRecords) +float TotalPaid(float fare[], float toll[], float total_fare, int totalRecords) { for (int j = 0; j < totalRecords; j++) //Do for the number of records { @@ -206,25 +206,21 @@ void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int psgr[], int { // To screen cout << "\n\t** People Transported: " - << NumPsgr(psgr, num_psgr, totalRecords) - << " **"; //Prints the total people transported to the screen - cout << "\n\t** Total Paid (rounded down to nearest dollar): " - << TotalPaid(fare, toll, total_fare, totalRecords) - << " **"; //Prints the total paid (all fares and tolls) to the screen - cout << "\n\t** Average Cost Per Person(Rounded down to nearest dollar: " + << NumPsgr(psgr, num_psgr, totalRecords) << " **"; //Prints the total people transported to the screen + cout << "\n\t** Total Paid: " + << TotalPaid(fare, toll, total_fare, totalRecords) << " **"; //Prints the total paid (all fares and tolls) to the screen + cout << "\n\t** Average Cost Per Person: " << TotalPaid(fare, toll, total_fare, totalRecords) / NumPsgr(psgr, num_psgr, totalRecords) - << " **\n"; //Prints the average cost per person to the screen - cout << "\t\t The End \n"; //Prints "The End" to the screen + << " **\n" + << "\t\t The End \n"; //Prints the average cost per person to the screen // To file outFile << "\n\t** People Transported: " - << NumPsgr(psgr, num_psgr, totalRecords) - << " **"; //Prints the total people transported to the out file - outFile << "\n\t** Total Paid (rounded down to nearest dollar): " - << TotalPaid(fare, toll, total_fare, totalRecords) - << " **"; //Prints the total paid (all fares and tolls) to the out file - outFile << "\n\t** Average Cost Per Person(Rounded down to nearest dollar: " + << NumPsgr(psgr, num_psgr, totalRecords) << " **"; //Prints the total people transported to the out file + outFile << "\n\t** Total Paid: " + << TotalPaid(fare, toll, total_fare, totalRecords) << " **"; //Prints the total paid (all fares and tolls) to the out file + outFile << "\n\t** Average Cost Per Person: " << TotalPaid(fare, toll, total_fare, totalRecords) / NumPsgr(psgr, num_psgr, totalRecords) - << " **\n"; //Prints the average cost per person to the out file - outFile << "\t\t The End \n"; //Prints "The End" to the out file + << " **\n" + << "\t\t The End \n"; //Prints the average cost per person to the out file }
\ No newline at end of file |