summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortafaar <[email protected]>2022-11-28 21:46:58 -0800
committertafaar <[email protected]>2022-11-28 21:46:58 -0800
commita185ab3c5bd06617dc5f57b2d5b412d8c4cc8509 (patch)
tree1580005102697e20543420e21d9f589b57238258
parentname (diff)
downloadcst116-lab3-hill-a185ab3c5bd06617dc5f57b2d5b412d8c4cc8509.tar.xz
cst116-lab3-hill-a185ab3c5bd06617dc5f57b2d5b412d8c4cc8509.zip
small edits
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj1
-rw-r--r--BlankConsoleLab/BlankConsoleLab.vcxproj.filters3
-rw-r--r--BlankConsoleLab/CST116-Lab3-Hill-Flowchart.txt141
3 files changed, 145 insertions, 0 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj b/BlankConsoleLab/BlankConsoleLab.vcxproj
index ac9affa..b861d5b 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj
@@ -143,6 +143,7 @@
</ItemGroup>
<ItemGroup>
<Text Include="big.txt" />
+ <Text Include="CST116-Lab3-Hill-Flowchart.txt" />
<Text Include="small.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
index 2ae2465..44aeca5 100644
--- a/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
+++ b/BlankConsoleLab/BlankConsoleLab.vcxproj.filters
@@ -26,5 +26,8 @@
<Text Include="big.txt">
<Filter>Source Files</Filter>
</Text>
+ <Text Include="CST116-Lab3-Hill-Flowchart.txt">
+ <Filter>Source Files</Filter>
+ </Text>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/BlankConsoleLab/CST116-Lab3-Hill-Flowchart.txt b/BlankConsoleLab/CST116-Lab3-Hill-Flowchart.txt
new file mode 100644
index 0000000..27a4cb8
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab3-Hill-Flowchart.txt
@@ -0,0 +1,141 @@
+// OUTPUT (Both big.txt and small.txt are tested in one run) //
+Please enter your data file name with the .txt extension:
+oops
+
+Failed to open oops
+
+Please enter your data file name with the .txt extension:
+small
+
+Failed to open small
+
+Please enter your data file name with the .txt extension:
+small.txt
+
+Opened small.txt
+
+TOTAL PASSENGERS: 14
+TOTAL PAID: $113.52
+AVG COST PER PERSON: $8.11
+TOTAL TRIPS: 6
+
+Would you like to display a table? Y/N
+Y
+
+ENTRY PICKUP DROPOFF #PASS DIST FARE$ TOLL$ TOTAL$ $/MILE
+1 129 7 3 1.30 7.50 0.00 7.50 5.77
+2 36 69 1 11.41 32.00 5.76 37.76 2.80
+3 7 41 1 4.60 15.00 5.76 20.76 3.26
+4 150 61 2 6.75 23.00 0.00 23.00 3.41
+5 112 17 1 3.84 15.00 0.00 15.00 3.91
+6 80 112 6 1.64 9.50 0.00 9.50 5.79
+
+Would you like to open another file? Y/N
+Y
+
+Please enter your data file name with the .txt extension:
+big.txt
+
+Opened big.txt
+
+TOTAL PASSENGERS: 100
+TOTAL PAID: $1052.04
+AVG COST PER PERSON: $10.52
+TOTAL TRIPS: 48
+
+Would you like to display a table? Y/N
+A
+
+Would you like to display a table? Y/N
+N
+
+Would you like to open another file? Y/N
+A
+
+Would you like to open another file? Y/N
+N
+
+// PSEUDO-CODE //
+
+DEFINE a FUNCTION that RETURNS an INTEGER ReadFile(INFILE REFERENCE file){
+
+ SET INTEGER counter TO -1;
+
+ WHILE (file IS NOT AT THE END){
+
+ SET each appropriate ARRAY value at [counter] TO VALUE FROM file;
+
+ SET totalFare[counter] TO fareAmount[counter] + tollAmount[counter];
+
+ IF (distanceTravelled[counter] IS NOT 0){
+
+ SET costPerMile[counter] TO (totalFare[counter] / distanceTravelled[counter]);
+
+ }ELSE SET costPerMile[counter] TO 0;
+
+ }
+
+}
+
+DEFINE a NULL RETURN FUNCTION GenerateTotals(INTEGER numEntries){
+
+ DEFINE INTEGER totalPassengers;
+ DEFINE DOUBLE totalPaid;
+
+ SET totalPassengers TO SUM OF EACH passengerTotal;
+ SET totalPAID TO SUM OF EACH totalFare;
+
+ PRINT ([Total passengers, Total paid, Avg. cost per person (totalPaid / totalPassengers), Number of entries (total trips)]);
+
+}
+
+MAIN(){
+
+ DEFINE INFILE inFile;
+ INITIALIZE CHAR choice AT 'Y';
+
+ WHILE (choice IS 'Y'){
+
+ WHILE (inFile IS NOT OPEN){
+
+ TAKE INPUT for fileName;
+ TRY to OPEN fileName;
+
+ }
+
+ INITIALIZE INTEGER numEntries AT RETURN VALUE FROM ReadData USING inFile;
+
+ GenerateTotals USING numEntries;
+
+ SET choice TO 'A';
+
+ WHILE (choice IS NOT 'Y' AND choice IS NOT 'N'){
+
+ PRINT( "Do you want to print a table? Y/N" );
+
+ SET choice TO INPUT;
+
+ }
+
+ IF (choice IS 'Y'){
+
+ PRINT([Table of values from file]);
+
+ }
+
+ SET choice TO 'A';
+
+ WHILE (choice IS NOT 'Y' AND choice IS NOT 'N'){
+
+ PRINT( "Do you want to enter another file? Y/N" );
+
+ SET choice TO INPUT;
+
+ }
+
+ CLOSE file;
+
+ // Should loop if user entered Y
+
+ }
+} \ No newline at end of file