summaryrefslogtreecommitdiff
path: root/cst116-lab3-stark
diff options
context:
space:
mode:
Diffstat (limited to 'cst116-lab3-stark')
-rw-r--r--cst116-lab3-stark/BlankConsoleLab.vcxproj153
-rw-r--r--cst116-lab3-stark/BlankConsoleLab.vcxproj.filters27
-rw-r--r--cst116-lab3-stark/cst116-lab3-stark-psuedo-code.txt27
-rw-r--r--cst116-lab3-stark/cst116-lab3-stark.cpp81
-rw-r--r--cst116-lab3-stark/cst116-lab3-stark.txt76
-rw-r--r--cst116-lab3-stark/large.txt48
-rw-r--r--cst116-lab3-stark/small.txt6
7 files changed, 418 insertions, 0 deletions
diff --git a/cst116-lab3-stark/BlankConsoleLab.vcxproj b/cst116-lab3-stark/BlankConsoleLab.vcxproj
new file mode 100644
index 0000000..0cd3fe0
--- /dev/null
+++ b/cst116-lab3-stark/BlankConsoleLab.vcxproj
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectGuid>{3cecade6-3e15-4852-bd24-65bfe5d3a3aa}</ProjectGuid>
+ <RootNamespace>BlankConsoleLab</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ <ProjectName>cst116-lab3-stark</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <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>v143</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v143</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="cst116-lab3-stark.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="cst116-lab3-stark-psuedo-code.txt" />
+ <Text Include="large.txt" />
+ <Text Include="small.txt" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/cst116-lab3-stark/BlankConsoleLab.vcxproj.filters b/cst116-lab3-stark/BlankConsoleLab.vcxproj.filters
new file mode 100644
index 0000000..246f02a
--- /dev/null
+++ b/cst116-lab3-stark/BlankConsoleLab.vcxproj.filters
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="cst116-lab3-stark.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="small.txt" />
+ <Text Include="large.txt" />
+ <Text Include="cst116-lab3-stark-psuedo-code.txt" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/cst116-lab3-stark/cst116-lab3-stark-psuedo-code.txt b/cst116-lab3-stark/cst116-lab3-stark-psuedo-code.txt
new file mode 100644
index 0000000..ca35e98
--- /dev/null
+++ b/cst116-lab3-stark/cst116-lab3-stark-psuedo-code.txt
@@ -0,0 +1,27 @@
+Trenton Stark
+CST 116
+Lab 3 Psuedo Code
+
+Initialize a 50 element array (fares) with all 0s
+Initialize totalPass = 0
+
+Prompt the user for a file name (fName) and open prompted file, if file can't be opened print warning and loop,
+
+Print header row for table
+for each line in file:
+ Read line into variables pick, drop, pass, dist, fare, and toll
+ total = fare + toll
+ if dist = 0:
+ cosMi = 0
+ else:
+ cosMi = fare / dist
+
+ print row with pick, drop, pass, dist, fare, toll, total, and cosMi
+
+ totalPass = totalPass + pass
+ store fare into corresponding element of fares[] array
+
+totalPaid = sum of all elements in fares[]
+average = totalPaid / total pass
+
+Print totalPass, totalPaid, and average
diff --git a/cst116-lab3-stark/cst116-lab3-stark.cpp b/cst116-lab3-stark/cst116-lab3-stark.cpp
new file mode 100644
index 0000000..b4cca4c
--- /dev/null
+++ b/cst116-lab3-stark/cst116-lab3-stark.cpp
@@ -0,0 +1,81 @@
+// Trenton Stark
+// CST 116
+// Lab 3
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <iomanip>
+
+using std::cout;
+using std::cin;
+using std::endl;
+using std::ifstream;
+using std::string;
+using std::setw;
+using std::setprecision;
+using std::fixed;
+
+const int width = 10; //Affects all tables
+
+void readFile(ifstream& fin, double fares[], int& totalPass);
+void summary(double fares[], int& totalPass);
+
+int main() {
+ ifstream fin;
+ string fName;
+ double fares[50] = { 0 }; //Initializes all cells to 0
+ int totalPass = 0;
+
+ //Loops prompt until user enters openable file
+ do {
+ cout << "Input file name: ";
+ cin >> fName;
+ fin.open(fName);
+ if (!(fin.is_open())) {
+ cout << "File couldn't be opened. Try again." << endl;
+ }
+ } while (!(fin.is_open()));
+ cout << endl;
+
+ cout << setw(width) << "Pick:" << setw(width) << "Drop:" << setw(width) << "Pass #:" << setw(width) << "Dist:" << setw(width) << "Fare:" << setw(width) << "Toll:" << setw(width) << "Total:" << setw(width) << "Cost/Mi:" << endl;
+ readFile(fin, fares, totalPass); //Inputs data into fares and totalPass while printing out file contents
+ summary(fares, totalPass); //Uses fares and totalPass to create a summary
+}
+
+void readFile(ifstream& fin, double fares[], int& totalPass) {
+ int i = 0;
+ int pick, drop, pass;
+ double dist, fare, toll, total, cosMi;
+
+ cout << fixed << setprecision(2); //Formats the output down to two decimal points
+ while (!(fin.eof())) {
+ fin >> pick >> drop >> pass >> dist >> fare >> toll;
+ total = fare + toll;
+ if (dist == 0) { //Checks if there will be a division by zero, if so set cosMi to 0
+ cosMi = 0;
+ }
+ else {
+ cosMi = fare / dist;
+ }
+ cout << setw(width) << pick << setw(width) << drop << setw(width) << pass << setw(width) << dist << setw(width) << fare << setw(width) << toll << setw(width) << total << setw(width) << cosMi << endl;
+
+ totalPass += pass;
+ fares[i] = total;
+ i++;
+ }
+ cout << endl;
+}
+
+void summary(double fares[], int& totalPass) {
+ float totalPaid = 0, average; //Totals paid must start as zero because each cell is added to the total
+ int i;
+ for (i = 0; i < 50; i++) { //Adds all cells regardless of how many were written because unwritten cells will be 0
+ totalPaid += fares[i];
+ }
+ average = totalPaid / totalPass;
+
+ cout << "Total Passangers: " << totalPass << endl;
+ cout << "Total Fares: " << totalPaid << endl;
+ cout << "Mean fare per passanger: " << average << endl;
+}
diff --git a/cst116-lab3-stark/cst116-lab3-stark.txt b/cst116-lab3-stark/cst116-lab3-stark.txt
new file mode 100644
index 0000000..fa7f388
--- /dev/null
+++ b/cst116-lab3-stark/cst116-lab3-stark.txt
@@ -0,0 +1,76 @@
+Trenton Stark
+CST 116
+Lab 3 Outpu
+
+small.txt:
+Input file name: small.txt
+
+ Pick: Drop: Pass #: Dist: Fare: Toll: Total: Cost/Mi:
+ 129 7 3 1.30 7.50 0.00 7.50 5.77
+ 36 69 1 11.41 32.00 5.76 37.76 2.80
+ 7 41 1 4.60 15.00 5.76 20.76 3.26
+ 150 61 2 6.75 23.00 0.00 23.00 3.41
+ 112 17 1 3.84 15.00 0.00 15.00 3.91
+ 80 112 6 1.64 9.50 0.00 9.50 5.79
+
+Total Passangers: 14
+Total Fares: 113.52
+Mean fare per passanger: 8.11
+
+large.txt:
+Input file name: large.txt
+
+ Pick: Drop: Pass #: Dist: Fare: Toll: Total: Cost/Mi:
+ 129 7 3 1.30 7.50 0.00 7.50 5.77
+ 36 69 1 11.41 32.00 5.76 37.76 2.80
+ 7 41 1 4.60 15.00 5.76 20.76 3.26
+ 150 61 2 6.75 23.00 0.00 23.00 3.41
+ 112 17 1 3.84 15.00 0.00 15.00 3.91
+ 80 112 6 1.64 9.50 0.00 9.50 5.79
+ 256 183 1 16.08 44.50 0.00 44.50 2.77
+ 138 166 2 7.40 24.50 6.12 30.62 3.31
+ 142 50 5 1.70 8.00 0.00 8.00 4.71
+ 107 163 0 3.60 17.00 0.00 17.00 4.72
+ 132 3 2 19.10 52.00 6.12 58.12 2.72
+ 48 41 1 4.07 18.00 4.36 22.36 4.42
+ 132 226 1 14.30 39.00 0.00 39.00 2.73
+ 229 151 1 3.96 14.50 4.58 19.08 3.66
+ 238 166 1 0.76 4.50 0.00 4.50 5.92
+ 151 238 2 0.64 5.00 2.20 7.20 7.81
+ 138 82 4 3.00 12.00 0.00 12.00 4.00
+ 264 231 3 10.74 32.50 0.00 32.50 3.03
+ 170 114 5 2.01 9.00 0.00 9.00 4.48
+ 186 87 2 3.45 12.00 0.00 12.00 3.48
+ 209 256 1 3.79 17.00 0.00 17.00 4.49
+ 132 107 1 17.20 52.00 6.12 58.12 3.02
+ 232 112 1 3.10 11.00 0.00 11.00 3.55
+ 164 141 3 2.85 10.50 0.00 10.50 3.68
+ 129 7 3 1.30 7.50 0.00 7.50 5.77
+ 36 69 1 11.41 32.00 5.76 37.76 2.80
+ 7 41 1 4.60 15.00 5.76 20.76 3.26
+ 150 61 2 6.75 23.00 0.00 23.00 3.41
+ 112 17 1 3.84 15.00 0.00 15.00 3.91
+ 80 112 6 1.64 9.50 0.00 9.50 5.79
+ 256 183 1 16.08 44.50 0.00 44.50 2.77
+ 138 166 2 7.40 24.50 6.12 30.62 3.31
+ 142 50 5 1.70 8.00 0.00 8.00 4.71
+ 107 163 0 3.60 17.00 0.00 17.00 4.72
+ 132 3 2 19.10 52.00 6.12 58.12 2.72
+ 48 41 1 4.07 18.00 4.36 22.36 4.42
+ 132 226 1 14.30 39.00 0.00 39.00 2.73
+ 229 151 1 3.96 14.50 4.58 19.08 3.66
+ 238 166 1 0.76 4.50 0.00 4.50 5.92
+ 151 238 2 0.64 5.00 2.20 7.20 7.81
+ 138 82 4 3.00 12.00 0.00 12.00 4.00
+ 264 231 3 10.74 32.50 0.00 32.50 3.03
+ 170 114 5 2.01 9.00 0.00 9.00 4.48
+ 186 87 2 3.45 12.00 0.00 12.00 3.48
+ 209 256 1 3.79 17.00 0.00 17.00 4.49
+ 132 107 1 17.20 52.00 6.12 58.12 3.02
+ 232 112 1 3.10 11.00 0.00 11.00 3.55
+ 164 141 3 2.85 10.50 0.00 10.50 3.68
+ 164 141 3 2.85 10.50 0.00 10.50 3.68
+
+Total Passangers: 103
+Total Fares: 1062.54
+Mean fare per passanger: 10.32
diff --git a/cst116-lab3-stark/large.txt b/cst116-lab3-stark/large.txt
new file mode 100644
index 0000000..1c3dbbb
--- /dev/null
+++ b/cst116-lab3-stark/large.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
diff --git a/cst116-lab3-stark/small.txt b/cst116-lab3-stark/small.txt
new file mode 100644
index 0000000..840aa56
--- /dev/null
+++ b/cst116-lab3-stark/small.txt
@@ -0,0 +1,6 @@
+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