Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 10PC
Program Plan Intro

File Filter

Program Plan:

Main.cpp:

  • Include required header files.
  • Inside “main ()” function,
    • Create an object “file1” for input file stream.
    • Create an object “ofile” for output file stream.
    • Declare a class template
    • Declare character variables named “popChar”, and “ch”.
    • Till the end of file,
      • Convert each character and Enqueue the character using the function “enqueue ()”.
    • Close “file1”.
    • Until the stack gets empty,
      • Pop the character stack and write it on output file “ofile” using the function “dequeue ()”.
    • Close the output file“ofile”.
    • Open the output file “ofile”.
    • Till the end of file,
      • Get a character from queue and print it on the console screen.

DynQueue.h:

  • Include required header files.
  • Create template class
  • Declare a class named “DynQueue”. Inside the class,
    • Inside the “private” access specifier,
      • Create a structure named “QueueNode”.
        • Create an object for the template
        • Create a pointer named “next”.
      • Create two pointers named “front” and “rear”.
      • Declare a variable.
    • Inside “public” access specifier,
      • Declare constructor and destructor.
      • Declare the functions “enqueue ()”, “dequeue ()”, “isEmpty ()”, “isFull ()”, and “clear ()”.
  • Declare template class.
  • Give definition for the constructor.
    • Assign the values.
  • Declare template class.
  • Give definition for the destructor.
    • Call the function “clear ()”.
  • Declare template class.
  • Give function definition for “enqueue ()”.
    • Make the pointer “newNode” as null.
    • Assign “num” to newNode->value.
    • Make newNode->next as null.
    • Check whether the queue is empty using “isEmpty ()” function.
      • If the condition is true then, assign newNode to “front” and “rear”.
      • If the condition is not true then,
        • Assign newNode to rear->next
        • Assign newNode to “rear”.
      • Increment the variable “numItems”.
  • Declare template class.
  • Give function definition for “dequeue ()”.
    • Assign temp pointer as null.
    • Check if the queue is empty using “isEmpty ()” function.
      • If the condition is true then print “The queue is empty”.
      • If the condition is not true then,
        • Assign the value of front to the variable “num”.
        • Make front->next as “temp”.
        • Delete the front value
        • Make temp as front.
        • Decrement the variable “numItems”.
  • Declare template class.
  • Give function definition for “isEmpty ()”.
    • Assign “true” to a Boolean variable
    • Check if “numItems” is true.
      • If the condition is true then assign “false” to the variable.
    • Return the Boolean variable.
  • Declare template class.
  • Give function definition for “clear ()”.
    • Create an object for template.
      • Dequeue values from queue till the queue becomes empty using “while” condition.

Blurred answer
Students have asked these similar questions
Word List File Reader This exercise assumes you have completed the Programming Exercise 7, Word List FileWriter. Write another program that reads the words from the file and displays the following data:• The number of words in the file.• The longest word in the file.• The average length of all of the words in the file
phyton Topics: list and list processing You will write a program to read grade data from a text file, displays the grades as a 5-column table, and then print the statistics (min, max, median, and median).   You can assume that the input file only one number per line.  You can assume the user always enter a file that exists. The median is the value in the middle of a sorted list.  To sort a list, use list.sort() function.  It’s computed as below. For a list of odd length, the middle number is just the length divide by 2.   For the list, [1,2,3], the median is 2 since 2 is in the middle of the list. The middle index is 3//2, which is 1. Remember that // is the integer division operator. When the length of the list is even, there are two middle numbers.  The median is the average of the two middle numbers.  For example, [1,2,3,4], the median is (2+3)/2 = 2.5.  The two middle indexes for this example are (4//2)-1 = 1 and (4//2) = 2.  Functions you need to write: read_grades() Prompts…
File Analysis USING PYTHON- DICTIONARY NOTE FIND ATTACHED BELOW 2 FILES THA SHOULD BE USED FOR THIS ASSIGNMENT Using python, Write a program that reads the contents of two text files and compares them in the followingways:It should display a list of all the unique words contained in both files.It should display a list of the words that appear in both files.It should display a list of the words that appear in the first file but not the second.It should display a list of the words that appear in the second file but not the first.It should display a list of the words that appear in either the first or second file, but notboth.Hint: Use set operations to perform these analyses. ATTACHED FILES  first FILENAME: first_file.txt The quick brown fox jumps over the lazy dog. Second FILENAME: second_file.txt Jack be nimble, Jack be quick, Jack jump over the candlestick.   . For the program, you need to write: Comments for all the values, constants, and functions IPO Variables Pseudocode

Chapter 19 Solutions

Starting Out with C++ from Control Structures to Objects (9th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr