summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobdw22 <[email protected]>2022-11-28 18:54:50 -0800
committerjacobdw22 <[email protected]>2022-11-28 18:54:50 -0800
commitb27ca86dfec904e5586cc20d6d48c4bc00f83a25 (patch)
treee3583763ad41bb76be3e0bce52ed51da999a6a04
parentAdded totals for the fares and for the passengers to the end. (diff)
downloadarchived-cst116-lab3-jacobdw22-b27ca86dfec904e5586cc20d6d48c4bc00f83a25.tar.xz
archived-cst116-lab3-jacobdw22-b27ca86dfec904e5586cc20d6d48c4bc00f83a25.zip
Added pseudo code to everything caught up
-rw-r--r--BlankConsoleLab/cst116-lab3-wilson.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/BlankConsoleLab/cst116-lab3-wilson.cpp b/BlankConsoleLab/cst116-lab3-wilson.cpp
index 6d151da..17ff26b 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);
+int TotalPaid(float fare[], float toll[], float total_fare, int totalRecords); //Defines function that calculates the total paid
///////////////////////////// Main Function /////////////////////////////
@@ -48,7 +48,7 @@ int main()
int record_counter(0); //Defines an int that tracks the number of records taken
int num_psgr = 0; //Defines variable for number of passengers
- float total_fare = 0.0;
+ float total_fare = 0.0; //Defines variable for the total fare
ifstream inFile; //Adds an infile to be used later
ofstream outFile; //Adds an outfile to be used later
@@ -176,7 +176,7 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int
}
}
-///////////////////////////// People Traansported Function /////////////////////////////
+///////////////////////////// People Transported Function /////////////////////////////
int NumPsgr(int psgr[], int num_psgr, int totalRecords)
{
@@ -187,7 +187,7 @@ int NumPsgr(int psgr[], int num_psgr, int totalRecords)
return num_psgr; //Return number of passengers
}
-
+///////////////////////////// Total Paid Function /////////////////////////////
int TotalPaid(float fare[], float toll[], float total_fare, int totalRecords)
{
@@ -203,13 +203,16 @@ int TotalPaid(float fare[], float toll[], float total_fare, int totalRecords)
void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int psgr[], int num_psgr, float fare[], float toll[], float total_fare)
{
// To screen
- cout << "\n\t** People Transported: " << NumPsgr(psgr, num_psgr, totalRecords) << " **\n"; //Prints the total records to the screen
+ cout << "\n\t** People Transported: "
+ << NumPsgr(psgr, num_psgr, totalRecords) << " **\n"; //Prints the total records to the screen
cout << "\n\t** Total Paid (rounded down to nearest dollar): "
<< TotalPaid(fare, toll, total_fare, totalRecords) << " **\n"; //Prints the total paid (all fares and tolls) to the screen
cout << "\t\t The End \n"; //Prints The End to the screen
+
// To file
- outFile << "\n\t** People Transported: " << NumPsgr(psgr, num_psgr, totalRecords) << " **\n"; //Prints the total records to the out file
+ outFile << "\n\t** People Transported: "
+ << NumPsgr(psgr, num_psgr, totalRecords) << " **\n"; //Prints the total records to the out file
outFile << "\n\t** Total Paid (rounded down to nearest dollar): "
<< TotalPaid(fare, toll, total_fare, totalRecords) << " **\n"; //Prints the total paid (all fares and tolls) to the out file