diff options
| author | [email protected] <[email protected]> | 2022-11-30 22:48:43 -0800 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2022-11-30 22:48:43 -0800 |
| commit | 6a913af9b5a5df2aba3ed7f73e609c5b1e1c333c (patch) | |
| tree | bdb38638edd90281d27f86e7c6e12cc51f79bfbb /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | More success (diff) | |
| download | cst116-lab3-smith-benjamin-6a913af9b5a5df2aba3ed7f73e609c5b1e1c333c.tar.xz cst116-lab3-smith-benjamin-6a913af9b5a5df2aba3ed7f73e609c5b1e1c333c.zip | |
Yet another push. Nearing the deadline!!
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index e1318bf..384e3c4 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -17,6 +17,11 @@ float distance_trav[50], fare[50], toll[50]; double total_fare[50], cost_per_mile[50]; string filename = ""; + +void Other_Calculations(double money[], int count_var); +float Fare_Calc(double moneys[]); + + int main() { ifstream infile; @@ -27,14 +32,16 @@ int main() infile >> pickup[counter] >> dropoff[counter] >> passengers[counter] >> distance_trav[counter] >> fare[counter] >> toll[counter]; counter++; } + infile.close(); + } + else { + cout << "There was an error loading the in file. You may need to reset its address to one on your local device." << endl; + system("pause"); + return 0; } - infile.close(); - - //for (int counter = 0; counter < 50; counter++) - // cout << pickup[counter] << " " << dropoff[counter] << " " << passengers[counter] << " " << distance_trav[counter] << " " << fare[counter] << " " << toll[counter] << endl; - cout << "Please enter the name of the file you wish to export the results into: "; + cout << "Please enter the name of the file you wish to export the results into" << endl << "You must include the \".txt\" at the end of your file name: "; cin >> filename; ofstream outfile; @@ -48,6 +55,33 @@ int main() cost_per_mile[counting] = fare[counting] / distance_trav[counting]; else cost_per_mile[counting] = 0; + + outfile << total_fare[counting] << " " << cost_per_mile[counting] << endl; } + cout << "The file was correctly creating and/or written to" << endl; + outfile.close(); + } + else { + cout << "There was an error creating or writing to the file" << endl; + system("pause"); + return 0; + } + + return 0; +} + +void Other_Calculations(double money[], int count_var, int counting) { + cout << endl << endl << endl; + cout << "The total number of travellers is: " << count_var << "." << endl; + cout << "The total amount of the fares is: " << Fare_Calc(total_fare, counting) << "." << endl; + cout << "The average cost per person is: " << Fare_Calc(total_fare, counting) / count_var << "." << endl; +} + +float Fare_Calc(double moneys[], int counting) { + int sum = 0; + + for (int count_variable = 0; count_variable < counting; count_variable++) { + sum += total_fare[count_variable]; } + return sum; }
\ No newline at end of file |