diff options
| author | Evan <[email protected]> | 2022-11-23 17:38:24 -0800 |
|---|---|---|
| committer | Evan <[email protected]> | 2022-11-23 17:38:24 -0800 |
| commit | a3f751540a98bcf3334834a63a71ab62fa825168 (patch) | |
| tree | c1c02c53387c0cce89a8ebd0f07f8464628f2789 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | setw (diff) | |
| download | cst116-lab3-evanmihm-a3f751540a98bcf3334834a63a71ab62fa825168.tar.xz cst116-lab3-evanmihm-a3f751540a98bcf3334834a63a71ab62fa825168.zip | |
total+cpm
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 23839e7..f6eafcb 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -14,17 +14,16 @@ using std::accumulate; using std::ifstream; using std::ofstream; - const int MAX = 100; -int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[]); +int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], int totalfare, int cpm); void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], int counter); void PrintTotalsAndSummary(ofstream& out, int totalRecords); //the first 'array' is the descripption of what needs to be done in total 6 equations/things to do -//next tsxt is 6 cols by x rows +//next text is 6 cols by x rows int main() { @@ -36,7 +35,8 @@ int main() float toll[MAX]; int record_counter(0); - + int cpm{}; + int totalfare{}; ifstream inFile; @@ -46,7 +46,7 @@ int main() if (inFile.is_open()) { - record_counter = ReadData(inFile, pick, drop, psgr, dist, fare, toll); + record_counter = ReadData(inFile, pick, drop, psgr, dist, fare, toll, totalfare, cpm); inFile.close(); if (outFile.is_open()) @@ -67,15 +67,20 @@ int main() cout << "\n\n\t\t ** About to EXIT NOW! ** "; } +// totalfare = fare + toll; +// cpm = fare / dist; + return 0; } -int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[]) +int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], int totalfare, int cpm) { int counter = 0; + + inFile >> pick[counter] >> drop[counter] >> psgr[counter] >> dist[counter] >> fare[counter] >> toll[counter]; // Priming Read - cout << "Pick" << setw(12) << "Drop" << setw(14) << "Passangers" << setw(12) - << "Distance" << setw(14) << "Fare" << setw(14) << "Toll" << endl; + cout << "Pick" << setw(12) << "Drop" << setw(15) << "Passengers" << setw(12) + << "Distance" << setw(13) << "Fare" << setw(13) << "Toll" << endl; while (!inFile.eof()) { @@ -91,6 +96,8 @@ int ReadData(ifstream& inFile, int pick[], int drop[], int psgr[], float dist[], inFile >> pick[counter] >> drop[counter] >> psgr[counter] >> dist[counter] >> fare[counter] >> toll[counter]; } + cout << "Total Fare = " << totalfare << endl; + cout << "Cost Per Mile = " << cpm << endl; return counter; } @@ -99,6 +106,7 @@ void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], floa int counter) { outFile << " Here is the Output File" << endl; + for (int r = 0; r <= counter - 0; r++) { outFile << setiosflags(ios::left) |