diff options
| author | jacobdw22 <[email protected]> | 2022-11-28 19:37:27 -0800 |
|---|---|---|
| committer | jacobdw22 <[email protected]> | 2022-11-28 19:37:27 -0800 |
| commit | 1c8f93c3f615887d7bbd26d85ab7150c0cdcae14 (patch) | |
| tree | 12f87a1064bf87d25e9aee0d5bd441ad1c3a260e | |
| parent | Very slight edit (diff) | |
| download | cst116-lab3-jacobdw22-1c8f93c3f615887d7bbd26d85ab7150c0cdcae14.tar.xz cst116-lab3-jacobdw22-1c8f93c3f615887d7bbd26d85ab7150c0cdcae14.zip | |
Moved some areas around
| -rw-r--r-- | BlankConsoleLab/cst116-lab3-wilson.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/BlankConsoleLab/cst116-lab3-wilson.cpp b/BlankConsoleLab/cst116-lab3-wilson.cpp index 9dd8a4f..724ceb4 100644 --- a/BlankConsoleLab/cst116-lab3-wilson.cpp +++ b/BlankConsoleLab/cst116-lab3-wilson.cpp @@ -115,6 +115,9 @@ int ReadData(ifstream& inFile, ofstream& outFile, int pick[], int drop[], int ps while (!inFile.eof()) //While not the end of the in file { + float total_fare = fare[counter] + toll[counter]; //Defines float total_fare + float cost_per_mile = fare[counter] / dist[counter]; //Defines float cost_per_mile + cout << setiosflags(ios::left) << setw(5) << pick[counter] << resetiosflags(ios::left) << setw(10) << drop[counter] << resetiosflags(ios::left) << setw(12) << psgr[counter] @@ -122,10 +125,8 @@ int ReadData(ifstream& inFile, ofstream& outFile, int pick[], int drop[], int ps << resetiosflags(ios::left) << setw(14) << fare[counter] << resetiosflags(ios::left) << setw(14) << toll[counter] << endl; //Print infile data as a table - float total_fare = fare[counter] + toll[counter]; //Defines float total_fare cout << "Total fare: " << total_fare << "\n"; //Prints total_fare to the screen - float cost_per_mile = fare[counter] / dist[counter]; //Defines float cost_per_mile if (dist[counter] != 0) { //If distance is not 0 cout << "Cost per mile: " << cost_per_mile << "\n\n"; //Print cost per mile } @@ -156,6 +157,9 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int for (int r = 0; r <= counter - 1; r++) //Loop while there is still data in the input file { + float total_fare = fare[r] + toll[r]; //Adds variable total_fare + float cost_per_mile = fare[r] / dist[r]; //Define float for cost per mile + outFile << setiosflags(ios::left) << setw(5) << pick[r] << resetiosflags(ios::left) << setw(10) << drop[r] << resetiosflags(ios::left) << setw(12) << psgr[r] @@ -163,11 +167,9 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int << resetiosflags(ios::left) << setw(14) << fare[r] << resetiosflags(ios::left) << setw(14) << toll[r] << endl; //Print in file data as a table in the out file - float total_fare = fare[r] + toll[r]; //Adds variable total_fare outFile << "Total fare: " << total_fare << "\n"; //Prints total_fare to the out file - float cost_per_mile = fare[r] / dist[r]; //Define float for cost per mile - if (dist[r] != 0) { //If the value of dist array is not 0 + if (dist[r] != 0) { //If the value of array dist is not 0 outFile << "Cost per mile: " << cost_per_mile << "\n\n"; //Print cost per mile to out file } else { //Otherwise |