Question
C++ Help Write a program that implements a stack and a queue as fixed arrays (declare stack array size as 30 and queue array size
C++ Help Write a program that implements a stack and a queue as fixed arrays (declare stack array size as 30 and queue array size as 20).
Design the program to read in a file called "text.txt". The file should contain the following words, punctuation marks, and numbers: "A wonderful serenity has taken possession of my entire soul, like these sweet mornings at 7 of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing 5 single strokes at the present moment; and yet I feel that I never was a greater artist than now. When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I throw myself down among the tall grass by the trickling stream; and, as I lie close to"
Tasks:
1. Extract each word from the input file and push each word into the stack while ignoring numbers and punctuation marks until the stack is full. Stop pushing words onto the stack when it fills up.
2. Pop each word from the stack one word at a time and enqueue each word into the queue. If the queue fills up before all the words are popped from the stack, dequeue the words from the queue and write each word to the output file until the queue is empty, then continue the enqueue (until all words are popped from the stack) and added to the queue . Repeat this process until all the words are read from the input file and written to the output file. Flush all the remaining words from the stack and then the queue when the last word is read from the input file. Upon dequeuing each word from the queue, print it to a file called "text_result.rpt. Print no more than 10 words per line of output to the output file.
3. Compute and print the average word length and the total word count to the screen (do not include the numbers or punctuation marks in the count).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started