Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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.
- In protected, define the “transform ()” 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.
- Check the input file contains the line breaks.
- 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
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Task 4. Utility classes
Implement a Menu-Driven program of ArrayList class using the above scenario and perform the following operations.
Create an object of ArrayList class based on the scenario with explanations of the method
Create a method that will allow inserting an element to ArrayList Class based on the scenario. The input field must be validated as
Create a method to delete specific elements in the ArrayList with explanations of the method
CLASSES, DYNAMIC ARRAYS AND POINTERS
Define a class called textLines that will be used to store a list of lines of text (each line can be specified as a string).
Use a dynamic array to store the list. In addition, you should have a private data member that specifies the length of the list.
Create a constructor that takes a file name as parameter, and fills up the list with lines from the file. Make sure that you set the dynamic array to expand large enough to hold all the lines from the file. Also, create a constructor that takes an integer parameter that sets the size of an empty list.
in C++
Write member functions to:
remove and return the last line from the list
add a new line onto the end of the list, if there is room for it, otherwise print a message and expand the array
empty the entire list
return the number of lines still on the list
take two lists and return one combined list (with no duplicates)
copy constructor to support deep copying
remember the destructor!
Computer Science
JAVASCRIPT .xlsx parser
I need to write a public class that reads an .xlsx file and returns an array of data in javascript. The array would be all of the data inside of the file.
The file itself is going to be inside of a folder(downloadedFIles) inside of my project. So the public class will need to account for that.
Chapter 15 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 15.3 - Prob. 15.1CPCh. 15.3 - Prob. 15.2CPCh. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - What will the following program display? #include...Ch. 15.3 - How can you tell from looking at a class...Ch. 15.3 - What makes an abstract class different from other...Ch. 15.3 - Examine the following classes. The table lists the...Ch. 15 - A class that cannot be instantiated is a(n) _____...
Ch. 15 - A member function of a class that is not...Ch. 15 - A class with at least one pure virtual member...Ch. 15 - In order to use dynamic binding, a member function...Ch. 15 - Static binding takes place at _____ time.Ch. 15 - Prob. 6RQECh. 15 - Prob. 7RQECh. 15 - Prob. 8RQECh. 15 - The is-a relation between classes is best...Ch. 15 - The has-a relation between classes is best...Ch. 15 - If every C1 class object can be used as a C2 class...Ch. 15 - A collection of abstract classes defining an...Ch. 15 - The keyword _____ prevents a virtual member...Ch. 15 - To have the compiler check that a virtual member...Ch. 15 - C++ Language Elements Suppose that the classes Dog...Ch. 15 - Will the statement pAnimal = new Cat; compile?Ch. 15 - Will the statement pCreature = new Dog ; compile?Ch. 15 - Will the statement pCat = new Animal; compile?Ch. 15 - Rewrite the following two statements to get them...Ch. 15 - Prob. 20RQECh. 15 - Find all errors in the following fragment of code,...Ch. 15 - Soft Skills 22. Suppose that you need to have a...Ch. 15 - Prob. 1PCCh. 15 - Prob. 2PCCh. 15 - Sequence Sum A sequence of integers such as 1, 3,...Ch. 15 - Prob. 4PCCh. 15 - File Filter A file filter reads an input file,...Ch. 15 - Prob. 6PCCh. 15 - Bumper Shapes Write a program that creates two...Ch. 15 - Bow Tie In Tying It All Together, we defined a...
Knowledge Booster
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
- In a new file named runner.cpp, define the Runner class, whose purpose is to hold the profile data for a user and maintain a record of their activities. The Runner class should have the following members • private variables for: username (string), age (integer, in years), weight (integer, in kg), height (integer, in cm), runList (list container of Run objects 2)arrow_forward1. Declare a (local) variable of type Person, create a new Object and assign the variable to this object. 2. Declare an ArrayList variable which can hold objects of type Person 3. Create a new ArrayList with objects of type Person and assign it to the existing variable persons.arrow_forwardComputer Science Part 2: Client Program with ArrayList Create a second client program. This program will contain an ArrayList of StudentGrades objects. The program will perform the following tasks: Create an instance of an ArrayList that will store three StudentGrades objects. Each element in the ArrayList represents student grades for a test (assessment). This means that each StudentGrades object stored by the ArrayList element represents the grades achieved by students for a single test. Prompt the user for the number of students in the class. The prompt text is: Enter the number of students in the course: [Keyboard Input] Add three new StudentGrades objects to the ArrayList. The StudentGrades objects should be populated with random values from 0 to 100. Use the enhanced for loop to print each of the StudentGrades objects to the console. Print a line containing the following text: “LAST ELEMENT BEFORE REMOVE:”. Print the value of the final element in the ArrayList under the heading.…arrow_forward
- 1- The FloatArray class stores a dynamic array of floats and its size. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the end of the array.- Overloading for the insertion operator << to write the array to afile (ofstream)- Overloading for the extraction operator >> to read the array elements from the file (ifstream) and add them to the array.- A destructor to deallocate the array2- The SortedArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the right place in the arraysuch that the array remains sorted with every add. Don’t add to the array then sort but rather add in the right place.3- The FrontArray inherits from FloatArray. It has:- A parameterized constructor that takes the array size. - An add method that adds a float at the front of the array.4- The PositiveArray that inherits from SortedArray. It has:- A parameterized constructor…arrow_forwardCollection: List, Set and Map. Collection operations on primitives and custom object (Eg: For custom object Student having properties ID and Name) List , Set , Maparrow_forwardObserver pattern The PhoneModel class stores a phone number as a list of digits, and the Keypad class has this method: public void simulateKeyPresses(int numKeyPresses)(0 that allows the user to enter digits one at a time then save each digit in the list. The Screen wants to respond to each key being entered. Make the model notify the observers whenever a new digit is entered for the phone number. The first observer prints the newest digit out to the screen The second observer prints "Now dialing 12345678901.." out to the screen (where the number is the number the model has). Only the Screen class can print to the screen The model must be decoupled from the Other classes.arrow_forward
- class BinaryImage: def __init__(self): pass def compute_histogram(self, image): """Computes the histogram of the input image takes as input: image: a grey scale image returns a histogram as a list""" hist = [0]*256 return hist def find_otsu_threshold(self, hist): """analyses a histogram it to find the otsu's threshold assuming that the input hstogram is bimodal histogram takes as input hist: a bimodal histogram returns: an optimal threshold value (otsu's threshold)""" threshold = 0 return threshold def binarize(self, image): """Comptues the binary image of the the input image based on histogram analysis and thresholding take as input image: an grey scale image returns: a binary image""" bin_img = image.copy() return…arrow_forwardTask 4. Utility classes Implement a Menu-Driven program of ArrayList class using the above scenario and perform the following operations. a. Create an object of ArrayList class based on the scenario with explanations of the method used. b. Create a method that will allow inserting an element to ArrayList Class based on the scenario. The input field must be validated as necessary. C. Create a method to delete specific elements in the ArrayList with explanations of the method used.arrow_forwardList collection views of a map interfacearrow_forward
- What are the distinctions between an ArrayList and a Vector?Which collection class is best for data manipulation?arrow_forward17. Phone Book ArrayList Write a class named PhoneBookEntry that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program that creates at least five PhoneBookEntry objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList.arrow_forwardLibrary class: Fields: books as arraylist to store all the books available in the library B3 B1 B2 В4 B5 Constructor: Library() } : No parameterized constructor to create the books object Methods: 1. addBook(Book bookobj): to add a new book to the arraylist; send the book object as a parameter to this method. 2. searchBook(String name): search a book by a given name in the arraylist. if exits print bookX found; otherwise print not found!!! 3. RemoveBook(String name): to delete a book object from arraylist by a given name: Hint: you need to use iterator class and remove method. Book class: Fileds: bookld, bookname. Constructor: two parameterized constructor that accepts name a parameter Book(int ID, String name) ..... Methods: 1. Accessor method to return the name of the book 2. Mutator method to change the id of the book. Use this Main method: in your program: public static void main(String args[]) { Library lib=new Library(); lib.addBook(new Book("b1")); lib.addBook(new Book("b2"));…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT