Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download: http://solutionzip.com/downloads/stack-queue-fileread/
- The program will get the name of a .txt file from the user. It will open the file and read in data one item at a time. It will be looking for integers, in the file, that are between 0-99.
- When the program does a read, if the number read is between 0-49, the program will PUSH it to a STACK.
- When the program does a read, if the number read is between 50-99, the program will PUSH it to a QUEUE.
- If the data is invalid (such as an integer less than 0 or greater than 99, or if the data is a word or character) the program will discard that data and move on to the next read.
- The program needs to look for the end of file (EOF) to determine when it is done reading data.
- Once the reads are complete, the program will POP the data off of the STACK and write the data, ONE ITEM PER LINE THEN SKIP A LINE AND SUM THE TOTAL, to a .txt file named “stack.txt”.
- Once the reads are complete, the program will POP the data off of the QUEUE and write the data, ONE ITEM PER LINE THEN SKIP A LINE AND SUM THE TOTAL, to a .txt file named “queue.txt”.
- The program will need FUNCTIONS to do the following:
- A function that gets the name of the .txt file to open from the user
- A functions that reads the data from the file and evaluates if the data to be sorted
- A function that PUSHES data to the STACK
- A function that PUSHES data to the QUEUE
- A function that creates a .txt file named stack.txt and writes the data from the STACK and the sum in the file
- A function that creates a .txt file named queue.txt and writes the data from the QUEUE and the sum in the file
- A function that will open and display both .txt files that were created to the user at the CONSOLE
- USE ERROR CHECKING!
- Download: http://solutionzip.com/downloads/stack-queue-fileread/
Add Comment
Please, Sign In to add comment