summaryrefslogtreecommitdiff
path: root/BlankConsoleLab
diff options
context:
space:
mode:
authorMatthew Taeza <[email protected]>2022-11-29 20:17:21 -0800
committerMatthew Taeza <[email protected]>2022-11-29 20:17:21 -0800
commit4b501d9a8b097f2095ffe1a95361ad3a9cd14441 (patch)
tree36f7b38994962b5cf76681d9a31999574a442bb6 /BlankConsoleLab
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab3-matthewtaeza-4b501d9a8b097f2095ffe1a95361ad3a9cd14441.tar.xz
cst116-lab3-matthewtaeza-4b501d9a8b097f2095ffe1a95361ad3a9cd14441.zip
Submission
Diffstat (limited to 'BlankConsoleLab')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp95
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj12
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters8
3 files changed, 107 insertions, 8 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ed5f807..64c6659 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -2,15 +2,102 @@
//
#include <iostream>
-
-using namespace std;
+#include <iomanip>
+#include <fstream>
+#include <string>
using std::cout;
using std::cin;
-using std::endl;
+using namespace std;
+
+int PickUp[50];
+int DropOff[50];
+int Passenger[50];
+
+float Distance[50];
+float Fare[50];
+float Toll[50];
+float CPM[50]; //cost per minute
+
+double TotalCost[50];
+
+int NumberEntries;
+
+int ReadData(ifstream& file)
+{
+ int f = -1; //f is the number of entries
+
+ while (!file.eof())
+ {
+ f++;
+
+ file >> PickUp[f] >> DropOff[f] >> Passenger[f] >> Distance[f] >> Fare[f] >> Toll[f];
+
+ TotalCost[f] = Fare[f] + Toll[f];
+
+ if (Distance[f] != 0)
+ {
+ CPM[f] = Fare[f] / Distance[f];
+
+ }
+
+ else CPM[f] = 0;
+
+ }
+ f++;
+
+ return f;
+
+}
+
+void GenerateTotals(int NumberEntries)
+{
+ int PassengersTotal = 0;
+ double TotalPaid = 0;
+
+ for (int i = 0; i <= NumberEntries; i++)
+ {
+ PassengersTotal += Passenger[i];
+ TotalPaid += TotalCost[i];
+ }
+
+ cout << "Total passenger count ->> " << PassengersTotal << endl;
+ cout << "Total paid ->> " << TotalPaid << endl;
+ cout << "The average cost per person is ->> $" << TotalPaid / PassengersTotal << endl;
+ cout << "Total trips ->> " << NumberEntries << endl;
+
+}
int main()
{
- cout << "Hello World!\n";
+ ifstream inFile;
+ string fileName;
+
+ cout << fixed << setprecision(2);
+
+ while (!inFile.is_open()) {
+
+ cout << "Enter your file name with .txt extension ->>" << endl;
+ cin >> fileName;
+
+ inFile.open(fileName);
+
+ if (inFile.is_open()) {
+
+ cout << "\nOpened " << fileName << endl;
+
+ }
+ else {
+
+ cout << "\nCould not open " << fileName << endl;
+ }
+ cout << endl;
+ }
+
+ int NumberEntries = ReadData(inFile);
+
+ GenerateTotals(NumberEntries);
}
+
+
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index db2e734..33b172d 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>
@@ -141,6 +141,10 @@
<ItemGroup>
<ClCompile Include="BlankConsoleLab.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <Text Include="..\..\..\..\Downloads\large.txt" />
+ <Text Include="..\..\..\..\OneDrive\Desktop\small.txt" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index aca1dd9..a7b3600 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -19,4 +19,12 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <Text Include="..\..\..\..\Downloads\large.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ <Text Include="..\..\..\..\OneDrive\Desktop\small.txt">
+ <Filter>Source Files</Filter>
+ </Text>
+ </ItemGroup>
</Project> \ No newline at end of file