summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorMusa Ahmed <[email protected]>2022-11-30 17:48:53 -0800
committerMusa Ahmed <[email protected]>2022-11-30 17:48:53 -0800
commitaaea2967bc68003cb052c564e2009379d5481bcc (patch)
tree03e7d69f170938bf0e8264b4bf6b144fe82b259e /BlankConsoleLab
parentadded pseudocode and output files (diff)
downloadcst116-lab3-m005a-aaea2967bc68003cb052c564e2009379d5481bcc.tar.xz
cst116-lab3-m005a-aaea2967bc68003cb052c564e2009379d5481bcc.zip
renamed the files
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj2
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters2
-rw-r--r--BlankConsoleLab/CST116-Lab3-Output.txt91
-rw-r--r--BlankConsoleLab/CST116-Lab3-Pseudocode.txt73
-rw-r--r--BlankConsoleLab/Lab3-Ahmed.cpp170
-rw-r--r--BlankConsoleLab/large.txt48
-rw-r--r--BlankConsoleLab/out.txt59
-rw-r--r--BlankConsoleLab/read.txt19
-rw-r--r--BlankConsoleLab/small.txt11
-rw-r--r--BlankConsoleLab/temp.txt6
10 files changed, 2 insertions, 479 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index 4d48773..55930eb 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -139,7 +139,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="Lab3-Ahmed.cpp" />
+ <ClCompile Include="CST116-Lab3-Ahmed.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="CST116-Lab3-Output.txt" />
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index 2dfd9f0..7d7d39a 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="Lab3-Ahmed.cpp">
+ <ClCompile Include="CST116-Lab3-Ahmed.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/BlankConsoleLab/CST116-Lab3-Output.txt b/BlankConsoleLab/CST116-Lab3-Output.txt
deleted file mode 100644
index 9ae6094..0000000
--- a/BlankConsoleLab/CST116-Lab3-Output.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-OUTPUT FOR LARGE TEXT
-
-Please enter the input file name including extension:
-large.txt
-Trip Pick Drop # ppl Distance Fare Toll Total Cost per Mile
-0 129 7 3 1.3 7.5 0 7.5 5.77
-1 36 69 1 11.4 32 5.76 37.8 3.31
-2 7 41 1 4.6 15 5.76 20.8 4.51
-3 150 61 2 6.75 23 0 23 3.41
-4 112 17 1 3.84 15 0 15 3.91
-5 80 112 6 1.64 9.5 0 9.5 5.79
-6 256 183 1 16.1 44.5 0 44.5 2.77
-7 138 166 2 7.4 24.5 6.12 30.6 4.14
-8 142 50 5 1.7 8 0 8 4.71
-9 107 163 0 3.6 17 0 17 4.72
-10 132 3 2 19.1 52 6.12 58.1 3.04
-11 48 41 1 4.07 18 4.36 22.4 5.49
-12 132 226 1 14.3 39 0 39 2.73
-13 229 151 1 3.96 14.5 4.58 19.1 4.82
-14 238 166 1 0.76 4.5 0 4.5 5.92
-15 151 238 2 0.64 5 2.2 7.2 11.2
-16 138 82 4 3 12 0 12 4
-17 264 231 3 10.7 32.5 0 32.5 3.03
-18 170 114 5 2.01 9 0 9 4.48
-19 186 87 2 3.45 12 0 12 3.48
-20 209 256 1 3.79 17 0 17 4.49
-21 132 107 1 17.2 52 6.12 58.1 3.38
-22 232 112 1 3.1 11 0 11 3.55
-23 164 141 3 2.85 10.5 0 10.5 3.68
-24 129 7 3 1.3 7.5 0 7.5 5.77
-25 36 69 1 11.4 32 5.76 37.8 3.31
-26 7 41 1 4.6 15 5.76 20.8 4.51
-27 150 61 2 6.75 23 0 23 3.41
-28 112 17 1 3.84 15 0 15 3.91
-29 80 112 6 1.64 9.5 0 9.5 5.79
-30 256 183 1 16.1 44.5 0 44.5 2.77
-31 138 166 2 7.4 24.5 6.12 30.6 4.14
-32 142 50 5 1.7 8 0 8 4.71
-33 107 163 0 3.6 17 0 17 4.72
-34 132 3 2 19.1 52 6.12 58.1 3.04
-35 48 41 1 4.07 18 4.36 22.4 5.49
-36 132 226 1 14.3 39 0 39 2.73
-37 229 151 1 3.96 14.5 4.58 19.1 4.82
-38 238 166 1 0.76 4.5 0 4.5 5.92
-39 151 238 2 0.64 5 2.2 7.2 11.2
-40 138 82 4 3 12 0 12 4
-41 264 231 3 10.7 32.5 0 32.5 3.03
-42 170 114 5 2.01 9 0 9 4.48
-43 186 87 2 3.45 12 0 12 3.48
-44 209 256 1 3.79 17 0 17 4.49
-45 132 107 1 17.2 52 6.12 58.1 3.38
-46 232 112 1 3.1 11 0 11 3.55
-47 164 141 3 2.85 10.5 0 10.5 3.68
-
-
- ** Avg Cost Per Person: 10.5 **
-
-
- ** People Transported: 100 **
-
-
- ** Total Cost: 1052 **
- The End
-
-
-OUTPUT FOR SMALL TEXT
-
-
-Please enter the input file name including extension:
-small.txt
-Trip Pick Drop # ppl Distance Fare Toll Total Cost per Mile
-0 129 7 3 1.3 7.5 0 7.5 5.77
-1 36 69 1 11.4 32 5.76 37.8 3.31
-2 7 41 1 4.6 15 5.76 20.8 4.51
-3 150 61 2 6.75 23 0 23 3.41
-4 112 17 1 3.84 15 0 15 3.91
-5 80 112 6 1.64 9.5 0 9.5 5.79
-
-
- ** Avg Cost Per Person: 8.11 **
-
-
- ** People Transported: 14 **
-
-
- ** Total Cost: 113.52 **
- The End
-
-C:\Users\macho\source\repos\cst116-lab3-M005A\x64\Debug\BlankConsoleLab.exe (process 9692) exited with code 0.
-To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
-Press any key to close this window . . . \ No newline at end of file
diff --git a/BlankConsoleLab/CST116-Lab3-Pseudocode.txt b/BlankConsoleLab/CST116-Lab3-Pseudocode.txt
deleted file mode 100644
index 059fda7..0000000
--- a/BlankConsoleLab/CST116-Lab3-Pseudocode.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-Initialize a constant int MAX for the maximum amount of records, set to 50
-
-START MAIN
-
-initialize function ReadData, with input file, arrays, and counters
-initialize function WriteOutputFile with output file, counters, and arrays
-initialize PrintTotalsAndSummary with output file, counters, and arrays
-
-Initialize an array for each needed value, with the length being equal to max
-initialize record counter
-initialize people counter
-initialize payment counter
-
-initialize filename
-initialize input file
-initialize output file
-
-prompt the user to input a filename wiht extension
- set the input equal to filename
-
-open the file
-
-if the file is open
- call the function ReadData and have its return value be set into record_counter
-
- close the input file
-
- if the output file is open
- call the functions writeoutputfile and printotalsummary
- close the output file
-
- else
- print an error message
-else
- print an error message
-
-return 0
-
-END MAIN
-
-ReadData
-
- prints out headers corresponding to each array
- read in the first line of data from the input file and have it set to the first of each array
-
- while it is not the end of the file
- the totalfare at the current index is equal to the far + toll
- print out the arrays at the current index, formatting into a table
-
- if the distance at the current index is 0, the cost per mile is 0
- otherwise the cost per mile is equal to the total cost over the distance
-
- increment the index
- read data again
-
- return counter
-
-
-WriteOutputFile
-
- enter a for loop which goes until the end of the total records in the file
- print out all the modified data to the output file at the current index
-
-PrintTotalsAndSummary
-
- enter a for loop which goes until the end of the total records in the file
- set the total amount of people to the array of passCount at the index added together
- set a double temp equal to the far + toll at the current index
- paid += temp
- the totalFare at the current index is equal to temp
-
- print out the avg cost per person, # people transported, and the total cost to both
- the screen and the output file.
diff --git a/BlankConsoleLab/Lab3-Ahmed.cpp b/BlankConsoleLab/Lab3-Ahmed.cpp
deleted file mode 100644
index 72076d7..0000000
--- a/BlankConsoleLab/Lab3-Ahmed.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-
-#include <iostream>
-#include <fstream> // For the files!!!!
-#include <iomanip> // For manipulators & formatting options
-#include <string>
-#include<array>
-
-using std::cin;
-using std::cout;
-using std::endl;
-using std::setw;
-using std::ios;
-using std::string;
-using std::ifstream;
-using std::ofstream;
-using std::setprecision;
-
-
-
-// The max amount of records in one file
-const int MAX = 50;
-
-// initialize all functions
-int ReadData(ifstream& inFile, int pick[], int drop[], int passCount[], double distance[], double fare[], double toll[], double costPMile[], int counter, double totalFare[]);
-void WriteOutputFile(ofstream& outFile, int totalRecords, int people, int pick[], int drop[], int passCount[], double distance[], double fare[], double toll[], double costPMile[]);
-void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int people, int passCount[], double distance[], double fare[], double toll[], double totalFare[], double costPMile[], double paid);
-
-
-int main()
-{
- // initialize all arrays and counters
- int pick[MAX];
- int drop[MAX];
- int passCount[MAX];
- double distance[MAX];
- double fare[MAX];
- double toll[MAX];
- double totalFare[MAX] = { 0 };
- double costPMile[MAX] = { 0 };
- int record_counter(0);
- int people(0);
- int counter = 0;
- double paid = 0;
-
- // initialize files
- string filename;
- ifstream inFile;
- ofstream outFile("out.txt");
-
-
- cout << "Please enter the input file name including extension: " << endl;
- cin >> filename;
-
- // open the requested file
- inFile.open(filename);
-
- if (inFile.is_open())
- {
- // read the data from the file, and output the total number of records (store into arrays)
- record_counter = ReadData(inFile, pick, drop, passCount, distance, fare, toll, costPMile, counter, totalFare);
-
- // close the read file
- inFile.close();
-
- if (outFile.is_open())
- {
- // write the new data to the output file
- WriteOutputFile(outFile, record_counter, people, pick, drop, passCount, distance, fare, toll, costPMile);
- // output the summary both to screen and to file
- PrintTotalsAndSummary(outFile, record_counter, people, passCount, distance, fare, toll, totalFare, costPMile, paid);
- 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! ** ";
- }
- return 0;
-}
-int ReadData(ifstream& inFile, int pick[], int drop[], int passCount[], double distance[], double fare[], double toll[], double costPMile[], int counter, double totalFare[])
-{
-
- // print headers
- cout << setiosflags(ios::left) << setw(10) << "Trip" << setw(15)
- << "Pick" << setw(10) << "Drop" << setw(10)
- << "# ppl"
- << setw(10) << "Distance" << setw(10)
- << "Fare"
- << setw(10) << "Toll"
- << setw(10) << "Total"
- << setw(10) << "Cost per Mile" << endl;
-
- inFile >> pick[counter] >> drop[counter] >> passCount[counter] >> distance[counter] >> fare[counter] >> toll[counter]; // Priming Read
- // read all of the data into arrays
- while (!inFile.eof())
- {
- totalFare[counter] = fare[counter] + toll[counter];
- cout << setiosflags(ios::left) << setw(10) << counter << setw(15)
- << pick[counter]
- << setw(10) << drop[counter] << setw(10)
- << passCount[counter]
- << setw(10) << distance[counter] << setw(10)
- << fare[counter]
- << setw(10) << toll[counter] << setw(15)
- << totalFare[counter] << setw(10);
- // if distance is 0 then there is no cost per mile
- if (distance[counter] == 0) {
- costPMile[counter] = 0;
- }
- // cost per mile = (toll + fare) / distance
- else {
- costPMile[counter] = (toll[counter] + fare[counter]) / distance[counter];
- }
- cout << setprecision(3) << costPMile[counter];
- counter++;
- inFile >> pick[counter] >> drop[counter] >> passCount[counter] >> distance[counter] >> fare[counter] >> toll[counter];
- cout << endl;
-
- }
-
- return counter;
-}
-void WriteOutputFile(ofstream& outFile, int totalRecords, int people, int pick[], int drop[], int passCount[], double distance[], double fare[], double toll[], double costPMile[])
-{
-
- // write the same data to the output files
- outFile << " Here is the Output File" << endl;
- for (int r = 0; r < totalRecords; r++)
- {
-
- outFile << setiosflags(ios::left) << setw(15)
- << pick[r]
- << setw(15) << drop[r] << setw(15)
- << passCount[r]
- << setw(15) << distance[r] << setw(15)
- << fare[r]
- << setw(15) << toll[r]
- << setw(15) << costPMile[r] << endl;
- }
-
-}
-void PrintTotalsAndSummary(ofstream& outFile, int totalRecords, int people, int passCount[], double distance[], double fare[], double toll[], double totalFare[], double costPMile[], double paid)
-{
- // do the calculations for all of the totals.
- for (int i = 0; i < totalRecords; i++) {
- people += passCount[i];
- double temp = fare[i] + toll[i];
- paid += temp;
- totalFare[i] = temp;
-
- }
- // print ot screen
- cout << "\n\n\t** Avg Cost Per Person: " << paid/people << " **\n"
- << "\n\n\t** People Transported: " << people << " **\n"
- << "\n\n\t** Total Cost: " << setprecision(5) << paid << " **\n"
-
- << "\t\t The End \n";
- // print to output file
- outFile << "\n\n\t** Avg Cost Per Person: " << paid/people << " **\n"
- << "\n\n\t** People Transported: " << people << " **\n"
- << "\n\n\t** Total Cost: " << paid << " **\n"
- << "\t\t The End \n";
-}
-
diff --git a/BlankConsoleLab/large.txt b/BlankConsoleLab/large.txt
deleted file mode 100644
index 1c3dbbb..0000000
--- a/BlankConsoleLab/large.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-129 7 3 1.3 7.5 0
-36 69 1 11.41 32 5.76
-7 41 1 4.6 15 5.76
-150 61 2 6.75 23 0
-112 17 1 3.84 15 0
-80 112 6 1.64 9.5 0
-256 183 1 16.08 44.5 0
-138 166 2 7.4 24.5 6.12
-142 50 5 1.7 8 0
-107 163 0 3.6 17 0
-132 3 2 19.1 52 6.12
-48 41 1 4.07 18 4.36
-132 226 1 14.3 39 0
-229 151 1 3.96 14.5 4.58
-238 166 1 0.76 4.5 0
-151 238 2 0.64 5 2.2
-138 82 4 3 12 0
-264 231 3 10.74 32.5 0
-170 114 5 2.01 9 0
-186 87 2 3.45 12 0
-209 256 1 3.79 17 0
-132 107 1 17.2 52 6.12
-232 112 1 3.1 11 0
-164 141 3 2.85 10.5 0
-129 7 3 1.3 7.5 0
-36 69 1 11.41 32 5.76
-7 41 1 4.6 15 5.76
-150 61 2 6.75 23 0
-112 17 1 3.84 15 0
-80 112 6 1.64 9.5 0
-256 183 1 16.08 44.5 0
-138 166 2 7.4 24.5 6.12
-142 50 5 1.7 8 0
-107 163 0 3.6 17 0
-132 3 2 19.1 52 6.12
-48 41 1 4.07 18 4.36
-132 226 1 14.3 39 0
-229 151 1 3.96 14.5 4.58
-238 166 1 0.76 4.5 0
-151 238 2 0.64 5 2.2
-138 82 4 3 12 0
-264 231 3 10.74 32.5 0
-170 114 5 2.01 9 0
-186 87 2 3.45 12 0
-209 256 1 3.79 17 0
-132 107 1 17.2 52 6.12
-232 112 1 3.1 11 0
-164 141 3 2.85 10.5 0
diff --git a/BlankConsoleLab/out.txt b/BlankConsoleLab/out.txt
deleted file mode 100644
index addee3c..0000000
--- a/BlankConsoleLab/out.txt
+++ /dev/null
@@ -1,59 +0,0 @@
- Here is the Output File
-129 7 3 1.3 7.5 0 5.76923
-36 69 1 11.41 32 5.76 3.30938
-7 41 1 4.6 15 5.76 4.51304
-150 61 2 6.75 23 0 3.40741
-112 17 1 3.84 15 0 3.90625
-80 112 6 1.64 9.5 0 5.79268
-256 183 1 16.08 44.5 0 2.76741
-138 166 2 7.4 24.5 6.12 4.13784
-142 50 5 1.7 8 0 4.70588
-107 163 0 3.6 17 0 4.72222
-132 3 2 19.1 52 6.12 3.04293
-48 41 1 4.07 18 4.36 5.49386
-132 226 1 14.3 39 0 2.72727
-229 151 1 3.96 14.5 4.58 4.81818
-238 166 1 0.76 4.5 0 5.92105
-151 238 2 0.64 5 2.2 11.25
-138 82 4 3 12 0 4
-264 231 3 10.74 32.5 0 3.02607
-170 114 5 2.01 9 0 4.47761
-186 87 2 3.45 12 0 3.47826
-209 256 1 3.79 17 0 4.48549
-132 107 1 17.2 52 6.12 3.37907
-232 112 1 3.1 11 0 3.54839
-164 141 3 2.85 10.5 0 3.68421
-129 7 3 1.3 7.5 0 5.76923
-36 69 1 11.41 32 5.76 3.30938
-7 41 1 4.6 15 5.76 4.51304
-150 61 2 6.75 23 0 3.40741
-112 17 1 3.84 15 0 3.90625
-80 112 6 1.64 9.5 0 5.79268
-256 183 1 16.08 44.5 0 2.76741
-138 166 2 7.4 24.5 6.12 4.13784
-142 50 5 1.7 8 0 4.70588
-107 163 0 3.6 17 0 4.72222
-132 3 2 19.1 52 6.12 3.04293
-48 41 1 4.07 18 4.36 5.49386
-132 226 1 14.3 39 0 2.72727
-229 151 1 3.96 14.5 4.58 4.81818
-238 166 1 0.76 4.5 0 5.92105
-151 238 2 0.64 5 2.2 11.25
-138 82 4 3 12 0 4
-264 231 3 10.74 32.5 0 3.02607
-170 114 5 2.01 9 0 4.47761
-186 87 2 3.45 12 0 3.47826
-209 256 1 3.79 17 0 4.48549
-132 107 1 17.2 52 6.12 3.37907
-232 112 1 3.1 11 0 3.54839
-164 141 3 2.85 10.5 0 3.68421
-
-
- ** Avg Cost Per Person: 10.5204 **
-
-
- ** People Transported: 100 **
-
-
- ** Total Cost: 1052.04 **
- The End
diff --git a/BlankConsoleLab/read.txt b/BlankConsoleLab/read.txt
deleted file mode 100644
index d5ff001..0000000
--- a/BlankConsoleLab/read.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-129 7 3 1.3 7.5 0
-
-36 69 1 11.41 32 5.76
-
-7 41 1 4.6 15 5.76
-
-
-John 19
-Molly 23
-Tim 48
-Keil 42
-Trinh 21
-Musa 18
-Anthony 25
-Kevin 27
-Cheryl 32
-Kim 16
-Dave 25
-Will 34 \ No newline at end of file
diff --git a/BlankConsoleLab/small.txt b/BlankConsoleLab/small.txt
deleted file mode 100644
index 1fba087..0000000
--- a/BlankConsoleLab/small.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-129 7 3 1.3 7.5 0
-
-36 69 1 11.41 32 5.76
-
-7 41 1 4.6 15 5.76
-
-150 61 2 6.75 23 0
-
-112 17 1 3.84 15 0
-
-80 112 6 1.64 9.5 0 \ No newline at end of file
diff --git a/BlankConsoleLab/temp.txt b/BlankConsoleLab/temp.txt
deleted file mode 100644
index 94e4c00..0000000
--- a/BlankConsoleLab/temp.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-129 7 3 1.3 7.5 0 5.76923
-36 69 1 11.41 32 5.76 3.30938
-7 41 1 4.6 15 5.76 4.51304
-150 61 2 6.75 23 0 3.40741
-112 17 1 3.84 15 0 3.90625
-80 112 6 1.64 9.5 0 5.79268