Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write and a C++ program to implement a stack and a queue . Implement both the stack and Queue using fixed arrays ( declare your

Write and a C++ program to implement a stack and a queue . Implement both the stack and Queue using fixed arrays ( declare your stack arrays size 25 and your queue array size 15 . Implement it so that it is easy to change and recompile).

Design your program to read in a file of text called text.txt. The file will contain sentences the consist of words,

punctuation marks, and numbers.

  • Extract each word from the input file push it each word onto the stack (ignore numbers and punctuation marks) until the stack becomes full. Stop pushing words onto the stack when it fills up.
  • Then pop each word from the stack one word at and time and enqueue each word into the queue. If the queue fills up before all the words are popped from the stack start dequeuing the words from the queue and write each word to the output file until the queue is empty then resuming the enqueue (until all words are popped from the stack) and added to the queue . Repeat this process until all words are read from the input file and written to the output file. Flush all remaining words from the stack and then the queue when the last word is read from the input file (.e.g, the stack my not be full when last word is encountered). Upon dequeueing each word from the queue print it to a file called "text_out.txt. Print no more than 10 words per line of output to the output file, compute and print the average word length and the total word count to the screen.

* Test input data files will be provided...initially you can create your own

Average word length : 99

Total Word count : 99

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

7. Prepare an effective outline

Answered: 1 week ago

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago