summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab3-Pseudocode.txt
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/CST116-Lab3-Pseudocode.txt')
-rw-r--r--BlankConsoleLab/CST116-Lab3-Pseudocode.txt73
1 files changed, 73 insertions, 0 deletions
diff --git a/BlankConsoleLab/CST116-Lab3-Pseudocode.txt b/BlankConsoleLab/CST116-Lab3-Pseudocode.txt
new file mode 100644
index 0000000..059fda7
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab3-Pseudocode.txt
@@ -0,0 +1,73 @@
+Initialize a constant int MAX for the maximum amount of records, set to 50
+
+START MAIN
+
+initialize function ReadData, with input file, arrays, and counters
+initialize function WriteOutputFile with output file, counters, and arrays
+initialize PrintTotalsAndSummary with output file, counters, and arrays
+
+Initialize an array for each needed value, with the length being equal to max
+initialize record counter
+initialize people counter
+initialize payment counter
+
+initialize filename
+initialize input file
+initialize output file
+
+prompt the user to input a filename wiht extension
+ set the input equal to filename
+
+open the file
+
+if the file is open
+ call the function ReadData and have its return value be set into record_counter
+
+ close the input file
+
+ if the output file is open
+ call the functions writeoutputfile and printotalsummary
+ close the output file
+
+ else
+ print an error message
+else
+ print an error message
+
+return 0
+
+END MAIN
+
+ReadData
+
+ prints out headers corresponding to each array
+ read in the first line of data from the input file and have it set to the first of each array
+
+ while it is not the end of the file
+ the totalfare at the current index is equal to the far + toll
+ print out the arrays at the current index, formatting into a table
+
+ if the distance at the current index is 0, the cost per mile is 0
+ otherwise the cost per mile is equal to the total cost over the distance
+
+ increment the index
+ read data again
+
+ return counter
+
+
+WriteOutputFile
+
+ enter a for loop which goes until the end of the total records in the file
+ print out all the modified data to the output file at the current index
+
+PrintTotalsAndSummary
+
+ enter a for loop which goes until the end of the total records in the file
+ set the total amount of people to the array of passCount at the index added together
+ set a double temp equal to the far + toll at the current index
+ paid += temp
+ the totalFare at the current index is equal to temp
+
+ print out the avg cost per person, # people transported, and the total cost to both
+ the screen and the output file.