Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 6PC
Program Plan Intro

Removal of Line Breaks

Program Plan:

  • Include the required header files to the program.
  • Definition for filter class.
    • In public, declare the function for “do_Filter()”.
    • In protected, declare the function for “transform(char ch)”.
  • Include the required function prototypes.
  • Function definition of the function “do_Filter()”.
    • Declare the variable "letter" to get the character stored in the file.
    • Loop to check the end of file.
    • Output the characters to the file.
    • Get the character from the input file.
  • Derived class “Line_Break”.
    • In protected, define the “transform ()” function.
      • Inside the function return the value to the function.
    • In public, declare the “do_Filter ()” function.
  • Definition of “do_Filter ()” function.
    • Check the input file contains the line breaks.
      • If so, removal the line breaks and adds a space between the each word.
      • Otherwise, call the “transform ()” function.
    • Declare the “File_print()” function.
  • Define the main() function.
    • Declare the require variable to hold the input and output file.
    • Get the file name from the user.
    • Create an object for the input file.
    • Check the file open condition using “while” loop.
      • Exit the program for invalid filename.
    • Call the function “File_print()”.
    • Get the output file name from the user.
    • Create an object for the output file.
    • Check the file open condition using “while” loop.
      • Exit the program for invalid filename.
    • Creating an object for “Line_Break ()”.
    • Close output file.
    • Re open the file to print the content.
    • Close all files.
  • Function definition for the function “File_print()”.
    • Clear the content of the file.
    • Seek arbitrary position in the file.
    • Loop to check the end of file.
      • Print the character.
    • Clear the content of the file.
    • Seek arbitrary position in the file

Blurred answer
Students have asked these similar questions
3. Write the static method String[] filter(String[] strings, StringFilter filter) that applies the filter to the strings and returns an array containing the transformed string in Java. 4. Create the class CompositeStringFilter that implements the interface StringFilter. This class successively applies the filters in the array StringFilter[] filters (given as constructor argument) to s in Java.
Java code  8. Given an existing ArrayList named friendList, find the first index of a friend named Sasha and store it in a new variable named index.
Implement a LinkedList class that stores integers using dynamic memory and a proper main program to test it. The following member functions need to be properly implemented and tested: 1. Default constructor. 2. Parmetrized Constructor. 3. Sum. 4. Average. 5. InsertAtHead. 6. InsertAtTail. 7. Delete. 8. Pop. 9. Circular. 10. Display. Sample answer is also provided.

Chapter 15 Solutions

Starting Out with C++: Early 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++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning