summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdullah Havaldar <[email protected]>2022-11-29 17:29:54 -0800
committerAbdullah Havaldar <[email protected]>2022-11-29 17:29:54 -0800
commitf11f4f8cfe62ce0b62933cf6a9d191dc549eb1b6 (patch)
treef7e03fc706517e7a5ac476bbe013eb3c09a715c6
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab3-abd00l4h-f11f4f8cfe62ce0b62933cf6a9d191dc549eb1b6.tar.xz
cst116-lab3-abd00l4h-f11f4f8cfe62ce0b62933cf6a9d191dc549eb1b6.zip
read in file and all output
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp16
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj13
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters7
-rw-r--r--BlankConsoleLab/CST116-Lab3-Havaldar.cpp64
-rw-r--r--BlankConsoleLab/large.txt48
5 files changed, 126 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..6a532c9 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -29,26 +29,26 @@
<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 +139,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="BlankConsoleLab.cpp" />
+ <ClCompile Include="CST116-Lab3-Havaldar.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="large.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index aca1dd9..51c15a6 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -15,8 +15,13 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="BlankConsoleLab.cpp">
+ <ClCompile Include="CST116-Lab3-Havaldar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <Text Include="large.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/BlankConsoleLab/CST116-Lab3-Havaldar.cpp b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
new file mode 100644
index 0000000..a10cac4
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab3-Havaldar.cpp
@@ -0,0 +1,64 @@
+// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
+//
+
+#include <iostream>
+#include <iomanip>
+#include <fstream>
+
+using namespace std;
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+int main()
+{
+ string fileName;
+ int numLines = 0;
+
+ cout << "Please enter the input file name including extension: ";
+ cin >> fileName;
+
+ ifstream theFile(fileName);
+
+ int count = 1;
+ int pick;
+ int drop;
+ int ppl;
+ double dis;
+ double fare;
+ double toll;
+
+ double avg = 0;
+ int totalPpl = 0;
+ double totalCost = 0;
+
+ cout << "Trip" << setw(20) << "Pickup" << setw(20) << "Dropoff" << setw(20) << "#ppl" << setw(20) << "Distance" << setw(20) << "Fare" << setw(20) << "Toll" << setw(20) << "Total" << setw(20) << "Cost/Mi" << endl;
+
+ while (theFile >> pick >> drop >> ppl >> dis >> fare >> toll) {
+ double total = fare + toll;
+ double cpm = total / dis;
+ cout << count
+ << setw(20) << pick
+ << setw(20) << drop
+ << setw(20) << ppl
+ << setw(20) << dis
+ << setw(20) << fare
+ << setw(20) << toll
+ << setw(20) << total
+ << setw(20) << setprecision(3) << cpm << endl;
+ count++;
+ totalPpl += ppl;
+ totalCost += total;
+ }
+
+ avg = totalCost / totalPpl;
+
+ cout << " " << endl;
+ cout << " " << endl;
+ cout << " " << endl;
+ cout << left << setw(20) << "** Avg Cost Per Person: " << avg << " **" << endl;
+ cout << left << setw(20) << "** People Transported: " << totalPpl << " **" << endl;
+ cout << left << setw(20) << "** Total Cost: " << totalCost << " **" << endl;
+}
+
diff --git a/BlankConsoleLab/large.txt b/BlankConsoleLab/large.txt
new file mode 100644
index 0000000..1c3dbbb
--- /dev/null
+++ b/BlankConsoleLab/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