diff options
Diffstat (limited to 'Lab3/CST116-Lab3-Florea.cpp')
| -rw-r--r-- | Lab3/CST116-Lab3-Florea.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lab3/CST116-Lab3-Florea.cpp b/Lab3/CST116-Lab3-Florea.cpp index d392d95..6b9a7c7 100644 --- a/Lab3/CST116-Lab3-Florea.cpp +++ b/Lab3/CST116-Lab3-Florea.cpp @@ -1,4 +1,5 @@ // CST 116 - Andrei Florea - Lab 3 +// Take in a file input with data and display statistics about the file #include <iostream> @@ -19,6 +20,7 @@ void displayData(int[], int[], int[], int[], float[], float[], float[], float[], int main() { + // Create and initiate most variables, this is where the main function of code runs int pick_up_loc[50]; int drop_off_loc[50]; int pass_count[50]; @@ -29,7 +31,6 @@ int main() float total[50]; float cost_mi[50]; string file_name; - string data_contents; getFileName(file_name); fstream data_file; @@ -48,12 +49,14 @@ int main() void getFileName(string& name) { + // Ask user for file name, store it in name cout << "Enter the name of the file including extension: " << endl; cin >> name; } void readData(fstream& file, int pick[], int drop[], int passenger[], int trip[], float distance[], float fare[], float toll[], float total[], float cost_mi[]) { + // Take in each line of data and store it in the correct slot for each array int counter = 0; file >> pick[counter] >> drop[counter] >> passenger[counter] >> distance[counter] >> fare[counter] >> toll[counter]; total[counter] = fare[counter] + toll[counter]; @@ -89,6 +92,7 @@ void readData(fstream& file, int pick[], int drop[], int passenger[], int trip[] void displayData(int trip[], int pick[], int drop[], int passenger[], float distance[], float fare[], float toll[], float total[], float cost_mi[], int counter) { + // Using the arrays, display the data int total_people = 0; float total_cost = 0; |