summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5>2022-11-30 23:07:44 -0800
committerLloyd Crawford <Lloyd Crawford@LAPTOP-7HJCDLE5>2022-11-30 23:07:44 -0800
commit90992e800c4178ef00d51a4cb0184ceb636e7266 (patch)
tree88d37b659c5228aa543e9abf3cd56a6e4f4f446a
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab3-19-ruin-90992e800c4178ef00d51a4cb0184ceb636e7266.tar.xz
cst116-lab3-19-ruin-90992e800c4178ef00d51a4cb0184ceb636e7266.zip
Completed Lab3HEADmaster
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp16
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj11
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters2
-rw-r--r--BlankConsoleLab/CST116_Lab3_BlankConsoleLab_Crawford.cpp145
-rw-r--r--BlankConsoleLab/Large1.txt48
-rw-r--r--BlankConsoleLab/Small1.txt11
-rw-r--r--CST116_LAB3_Crawford.sln (renamed from BlankConsoleLab.sln)0
-rw-r--r--CST116_LAB3_Crawford_Pseudocode.txt124
-rw-r--r--CST116_Lab3_Crawford_Output.txt95
9 files changed, 430 insertions, 22 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
deleted file mode 100644
index ed5f807..0000000
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
-#include <iostream>
-
-using namespace std;
-
-using std::cout;
-using std::cin;
-using std::endl;
-
-int main()
-{
- cout << "Hello World!\n";
-}
-
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index db2e734..6d20af4 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -24,31 +24,32 @@
<ProjectGuid>{3cecade6-3e15-4852-bd24-65bfe5d3a3aa}</ProjectGuid>
<RootNamespace>BlankConsoleLab</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ <ProjectName>CST16_Lab3_Crawford</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -139,7 +140,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="BlankConsoleLab.cpp" />
+ <ClCompile Include="CST116_Lab3_BlankConsoleLab_Crawford.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index aca1dd9..fa2a605 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="BlankConsoleLab.cpp">
+ <ClCompile Include="CST116_Lab3_BlankConsoleLab_Crawford.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/BlankConsoleLab/CST116_Lab3_BlankConsoleLab_Crawford.cpp b/BlankConsoleLab/CST116_Lab3_BlankConsoleLab_Crawford.cpp
new file mode 100644
index 0000000..9c358dd
--- /dev/null
+++ b/BlankConsoleLab/CST116_Lab3_BlankConsoleLab_Crawford.cpp
@@ -0,0 +1,145 @@
+// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
+//CST 116_Lab 3_Crawford
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <iomanip>
+// note for me. Remember Palindrome issues in coding!!
+
+using namespace std;
+
+int Pick_up[50];
+int Drop_off[50];
+int Passenger_count[50];
+
+float Distance_travelled[50];
+float Fare_amount[50];
+float Toll_amount[50];
+float CPM[50];
+
+double Total_fare[50];
+
+int numEntries;
+
+int ReadData(ifstream& file)
+{
+ int t = -1;
+
+ while (!file.eof())
+ {
+ t++;
+
+ file >> Pick_up[t] >> Drop_off[t] >> Passenger_count[t] >> Distance_travelled[t] >> Fare_amount[t] >> Toll_amount[t];
+
+ Total_fare[t] = Fare_amount[t] + Toll_amount[t];
+
+ if (Distance_travelled[t] != 0)
+ {
+ CPM[t] = Fare_amount[t] / Distance_travelled[t];
+ }
+ else CPM[t] = 0;
+ }
+
+ t++;
+
+ return t;
+}
+
+
+void GenerateTotals(int numEntries)
+{
+ int Total_Passengers = 0;
+ double Total_Paid = 0;
+
+ for (int i = 0; i <= numEntries; i++)
+ {
+ Total_Passengers += Passenger_count[i];
+ Total_Paid += Total_fare[i];
+
+ }
+ cout << "Total Passengers: " << Total_Passengers << endl;
+ cout << "Total Paid: $" << Total_Paid << endl;
+ cout << "AVG Cost per Person: $" << Total_Paid / Total_Passengers << endl;
+ cout << "Total Trips: " << numEntries << endl;
+
+}
+
+int main()
+{
+ ifstream inFile;
+ string fileName;
+
+ cout << fixed << setprecision(2);
+ char choice = 'Y';
+
+ while (choice == 'Y')
+ {
+ while (!inFile.is_open())
+ {
+ cout << "Please enter data file name with the .txt extention" << endl;
+ cin >> fileName;
+
+ inFile.open(fileName);
+
+ if (inFile.is_open()) {
+ cout << "\nAccess Granted: " << fileName << endl;
+ }
+ else
+ {
+ cout << "\nError 404 Acess Denied....ahh ahh ahh you didn't say the magic word! ahh ahh ahh!" << fileName << endl;
+ }
+
+
+ cout << endl;
+ }
+
+
+ int numEntries = ReadData(inFile);
+
+ GenerateTotals(numEntries);
+
+
+ choice = 'A';
+
+ while (choice != 'Y' && choice != 'N')
+ {
+ cout << "\nWould you like a diplay table of the data? Y/N" << endl;
+ cin >> choice;
+ }
+
+
+ if (choice == 'Y')
+ {
+ cout << left << setw(10) << "\nEntry" << setw(10) << "Pickup"
+ << setw(10) << "Dropoff" << setw(10) << "#PASS"
+ << setw(10) << "DIST" << setw(10) << "Fares"
+ << setw(10) << "Tolls" << setw(10) << "Total$"
+ << setw(10) << "$/Mile" << endl;
+
+ for (int i = 0; i < numEntries; i++)
+ {
+ cout << left << setw(10) << i + 1 << Pick_up[i]
+ << setw(10) << Drop_off[i] << setw(10) << Passenger_count[i]
+ << setw(10) << Distance_travelled[i] << setw(10) << Fare_amount[i]
+ << setw(10) << Toll_amount[i] << setw(10) << Total_fare[i]
+ << setw(10) << CPM[i] << endl;
+
+ }
+ }
+ choice = 'A';
+
+ while (choice != 'Y' && choice != 'N')
+ {
+ cout << "\nWould you like to open another file? Y/N" << endl;
+ cin >> choice;
+ }
+
+
+ inFile.close();
+ cout << endl;
+ }
+
+
+}
+
diff --git a/BlankConsoleLab/Large1.txt b/BlankConsoleLab/Large1.txt
new file mode 100644
index 0000000..d9fa1b1
--- /dev/null
+++ b/BlankConsoleLab/Large1.txt
@@ -0,0 +1,48 @@
+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 \ No newline at end of file
diff --git a/BlankConsoleLab/Small1.txt b/BlankConsoleLab/Small1.txt
new file mode 100644
index 0000000..3d94536
--- /dev/null
+++ b/BlankConsoleLab/Small1.txt
@@ -0,0 +1,11 @@
+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.sln b/CST116_LAB3_Crawford.sln
index 8e981c8..8e981c8 100644
--- a/BlankConsoleLab.sln
+++ b/CST116_LAB3_Crawford.sln
diff --git a/CST116_LAB3_Crawford_Pseudocode.txt b/CST116_LAB3_Crawford_Pseudocode.txt
new file mode 100644
index 0000000..0988d34
--- /dev/null
+++ b/CST116_LAB3_Crawford_Pseudocode.txt
@@ -0,0 +1,124 @@
+int ReadData(ifstream& file)
+{
+ int t = -1;
+
+ while (!file.eof())
+ {
+ t++;
+
+ file >> Pick_up[t] >> Drop_off[t] >> Passenger_count[t] >> Distance_travelled[t] >> Fare_amount[t] >> Toll_amount[t];
+
+ Total_fare[t] = Fare_amount[t] + Toll_amount[t];
+
+ if (Distance_travelled[t] != 0)
+ {
+ CPM[t] = Fare_amount[t] / Distance_travelled[t];
+ }
+ else CPM[t] = 0;
+ }
+
+ t++;
+
+ return t;
+}
+Reads the data file and also does the math of the functions.
+
+void GenerateTotals(int numEntries)
+{
+ int Total_Passengers = 0;
+ double Total_Paid = 0;
+
+ for (int i = 0; i <= numEntries; i++)
+ {
+ Total_Passengers += Passenger_count[i];
+ Total_Paid += Total_fare[i];
+
+ }
+ cout << "Total Passengers: " << Total_Passengers << endl;
+ cout << "Total Paid: $" << Total_Paid << endl;
+ cout << "AVG Cost per Person: $" << Total_Paid / Total_Passengers << endl;
+ cout << "Total Trips: " << numEntries << endl;
+
+}
+Displays mathematical information as a totalled amount.
+
+int main()
+{
+ ifstream inFile;
+ string fileName;
+
+ cout << fixed << setprecision(2);
+ char choice = 'Y';
+
+ while (choice == 'Y')
+ {
+ while (!inFile.is_open())
+ {
+ cout << "Please enter data file name with the .txt extention" << endl;
+ cin >> fileName;
+
+ inFile.open(fileName);
+
+ if (inFile.is_open()) {
+ cout << "\nAccess Granted: " << fileName << endl;
+ }
+ else
+ {
+ cout << "\nError 404 Acess Denied....ahh ahh ahh you didn't say the magic word! ahh ahh ahh!" << fileName << endl;
+ }
+
+
+ cout << endl;
+ }
+
+
+ int numEntries = ReadData(inFile);
+
+ GenerateTotals(numEntries);
+
+
+ choice = 'A';
+
+ while (choice != 'Y' && choice != 'N')
+ {
+ cout << "\nWould you like a diplay table of the data? Y/N" << endl;
+ cin >> choice;
+ }
+
+
+ if (choice == 'Y')
+ {
+ cout << left << setw(10) << "\nEntry" << setw(10) << "Pickup"
+ << setw(10) << "Dropoff" << setw(10) << "#PASS"
+ << setw(10) << "DIST" << setw(10) << "Fares"
+ << setw(10) << "Tolls" << setw(10) << "Total$"
+ << setw(10) << "$/Mile" << endl;
+
+ for (int i = 0; i < numEntries; i++)
+ {
+ cout << left << setw(10) << i + 1 << Pick_up[i]
+ << setw(10) << Drop_off[i] << setw(10) << Passenger_count[i]
+ << setw(10) << Distance_travelled[i] << setw(10) << Fare_amount[i]
+ << setw(10) << Toll_amount[i] << setw(10) << Total_fare[i]
+ << setw(10) << CPM[i] << endl;
+
+ }
+ }
+ choice = 'A';
+
+ while (choice != 'Y' && choice != 'N')
+ {
+ cout << "\nWould you like to open another file? Y/N" << endl;
+ cin >> choice;
+ }
+
+
+ inFile.close();
+ cout << endl;
+ }
+
+
+}
+
+For some reason while I'm sure my code is correct the output somehow mixes my data by making my Pickup and Dropoff #'s into 1 number.
+It is currently 11:02 PM Pacific time. I appologize for shoddy work. \ No newline at end of file
diff --git a/CST116_Lab3_Crawford_Output.txt b/CST116_Lab3_Crawford_Output.txt
new file mode 100644
index 0000000..1552b2c
--- /dev/null
+++ b/CST116_Lab3_Crawford_Output.txt
@@ -0,0 +1,95 @@
+Please enter data file name with the .txt extention
+Small1.txt
+
+Access Granted: Small1.txt
+
+Total Passengers: 14
+Total Paid: $113.52
+AVG Cost per Person: $8.11
+Total Trips: 7
+
+Would you like a diplay table of the data? Y/N
+Y
+
+Entry Pickup Dropoff #PASS DIST Fares Tolls Total$ $/Mile
+1 1297 3 1.30 7.50 0.00 7.50 5.77
+2 3669 1 11.41 32.00 5.76 37.76 2.80
+3 741 1 4.60 15.00 5.76 20.76 3.26
+4 15061 2 6.75 23.00 0.00 23.00 3.41
+5 11217 1 3.84 15.00 0.00 15.00 3.91
+6 80112 6 1.64 9.50 0.00 9.50 5.79
+7 00 0 0.00 0.00 0.00 0.00 0.00
+
+Would you like to open another file? Y/N
+Y
+
+Please enter data file name with the .txt extention
+Large1.txt
+
+Access Granted: Large1.txt
+
+Total Passengers: 100
+Total Paid: $1052.04
+AVG Cost per Person: $10.52
+Total Trips: 48
+
+Would you like a diplay table of the data? Y/N
+Y
+
+Entry Pickup Dropoff #PASS DIST Fares Tolls Total$ $/Mile
+1 1297 3 1.30 7.50 0.00 7.50 5.77
+2 3669 1 11.41 32.00 5.76 37.76 2.80
+3 741 1 4.60 15.00 5.76 20.76 3.26
+4 15061 2 6.75 23.00 0.00 23.00 3.41
+5 11217 1 3.84 15.00 0.00 15.00 3.91
+6 80112 6 1.64 9.50 0.00 9.50 5.79
+7 256183 1 16.08 44.50 0.00 44.50 2.77
+8 138166 2 7.40 24.50 6.12 30.62 3.31
+9 14250 5 1.70 8.00 0.00 8.00 4.71
+10 107163 0 3.60 17.00 0.00 17.00 4.72
+11 1323 2 19.10 52.00 6.12 58.12 2.72
+12 4841 1 4.07 18.00 4.36 22.36 4.42
+13 132226 1 14.30 39.00 0.00 39.00 2.73
+14 229151 1 3.96 14.50 4.58 19.08 3.66
+15 238166 1 0.76 4.50 0.00 4.50 5.92
+16 151238 2 0.64 5.00 2.20 7.20 7.81
+17 13882 4 3.00 12.00 0.00 12.00 4.00
+18 264231 3 10.74 32.50 0.00 32.50 3.03
+19 170114 5 2.01 9.00 0.00 9.00 4.48
+20 18687 2 3.45 12.00 0.00 12.00 3.48
+21 209256 1 3.79 17.00 0.00 17.00 4.49
+22 132107 1 17.20 52.00 6.12 58.12 3.02
+23 232112 1 3.10 11.00 0.00 11.00 3.55
+24 164141 3 2.85 10.50 0.00 10.50 3.68
+25 1297 3 1.30 7.50 0.00 7.50 5.77
+26 3669 1 11.41 32.00 5.76 37.76 2.80
+27 741 1 4.60 15.00 5.76 20.76 3.26
+28 15061 2 6.75 23.00 0.00 23.00 3.41
+29 11217 1 3.84 15.00 0.00 15.00 3.91
+30 80112 6 1.64 9.50 0.00 9.50 5.79
+31 256183 1 16.08 44.50 0.00 44.50 2.77
+32 138166 2 7.40 24.50 6.12 30.62 3.31
+33 14250 5 1.70 8.00 0.00 8.00 4.71
+34 107163 0 3.60 17.00 0.00 17.00 4.72
+35 1323 2 19.10 52.00 6.12 58.12 2.72
+36 4841 1 4.07 18.00 4.36 22.36 4.42
+37 132226 1 14.30 39.00 0.00 39.00 2.73
+38 229151 1 3.96 14.50 4.58 19.08 3.66
+39 238166 1 0.76 4.50 0.00 4.50 5.92
+40 151238 2 0.64 5.00 2.20 7.20 7.81
+41 13882 4 3.00 12.00 0.00 12.00 4.00
+42 264231 3 10.74 32.50 0.00 32.50 3.03
+43 170114 5 2.01 9.00 0.00 9.00 4.48
+44 18687 2 3.45 12.00 0.00 12.00 3.48
+45 209256 1 3.79 17.00 0.00 17.00 4.49
+46 132107 1 17.20 52.00 6.12 58.12 3.02
+47 232112 1 3.10 11.00 0.00 11.00 3.55
+48 164141 3 2.85 10.50 0.00 10.50 3.68
+
+Would you like to open another file? Y/N
+N
+
+
+C:\Users\Lloyd Crawford\source\repos\cst116-lab3-19-Ruin\x64\Debug\CST16_Lab3_Crawford.exe (process 9768) 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 . . .