diff options
| author | Evan <[email protected]> | 2022-11-30 21:54:47 -0800 |
|---|---|---|
| committer | Evan <[email protected]> | 2022-11-30 21:54:47 -0800 |
| commit | b0f2aab4f1e2936074dd6794841222ec780552a4 (patch) | |
| tree | bfa5804ecc9975507b06a3aa3fa5f82ca1c0a455 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | fghjuytredf (diff) | |
| download | cst116-lab3-evanmihm-b0f2aab4f1e2936074dd6794841222ec780552a4.tar.xz cst116-lab3-evanmihm-b0f2aab4f1e2936074dd6794841222ec780552a4.zip | |
names
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp deleted file mode 100644 index e80c091..0000000 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ /dev/null @@ -1,134 +0,0 @@ -//lab3 -#include <iostream> -#include <fstream> -#include <iomanip> -#include <numeric> -#include <array> - -using std::cin; -using std::cout; -using std::endl; -using std::setw; -using std::ios; -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 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 text is 6 cols by x rows - -int main() -{ - int pick[MAX]; - int drop[MAX]; - int psgr[MAX]; - float dist[MAX]; - float fare[MAX]; - float toll[MAX]; - int record_counter(0); - - int cpm{}; - int totalfare{}; - - ifstream inFile; - - ofstream outFile("LabResults.txt"); - - inFile.open("infile.txt"); - - if (inFile.is_open()) - { - record_counter = ReadData(inFile, pick, drop, psgr, dist, fare, toll, totalfare, cpm); - inFile.close(); - - if (outFile.is_open()) - { - WriteOutputFile(outFile, pick, drop, psgr, dist, fare, toll, record_counter); - PrintTotalsAndSummary(outFile, record_counter); - outFile.close(); - } - else - { - cout << "Trouble Opening File"; - cout << "\n\n\t\t ** About to EXIT NOW! ** "; - } - } - else - { - cout << "Trouble Opening File"; - cout << "\n\n\t\t ** About to EXIT NOW! ** "; - } - - - totalfare = fare[MAX] + toll[MAX]; - return 0; -// totalfare = fare + toll; -// cpm = fare / dist; - -} -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(15) << "Passengers" << setw(12) - << "Distance" << setw(13) << "Fare" << setw(13) << "Toll" << endl; - - while (!inFile.eof()) - { - cout << setiosflags(ios::left) - << setw(5) << pick[counter] << resetiosflags(ios::left) - << setw(10) << drop[counter] << resetiosflags(ios::left) - << setw(12) << psgr[counter] << resetiosflags(ios::left) - << setw(14) << dist[counter] << resetiosflags(ios::left) - << setw(14) << fare[counter] << resetiosflags(ios::left) - << setw(14) << toll[counter] - << endl; - counter++; - 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; -} - -void WriteOutputFile(ofstream& outFile, int pick[], int drop[], int psgr[], float dist[], float fare[], float toll[], - int counter) -{ - outFile << " Here is the Output File" << endl; - - for (int r = 0; r <= counter - 0; r++) - { - outFile << setiosflags(ios::left) - << setw(5) << pick[r] << resetiosflags(ios::left) - << setw(10) << drop[r] << resetiosflags(ios::left) - << setw(12) << psgr[r] << resetiosflags(ios::left) - << setw(14) << dist[r] << resetiosflags(ios::left) - << setw(14) << fare[r] << resetiosflags(ios::left) - << setw(14) << toll[r] - << endl; - } -} -void PrintTotalsAndSummary(ofstream& outFile, int totalRecords) -{ - // To screen - cout << "\n\n\t** Total Records: " << totalRecords << " **\n" - << "\t\t The End \n"; - - // To file - outFile << "\n\n\t** Total Records: " << totalRecords << " **\n" - << "\t\t The End \n"; -} |