STARTING OUT WITH C++FROM CONTROL STRU
STARTING OUT WITH C++FROM CONTROL STRU
18th Edition
ISBN: 9781323815458
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 17, Problem 5PC
Program Plan Intro

Text File Analysis

Program plan

source.cpp

  • Include the required header files to the program.
  • Define the main() function,
    • Include the required function prototype to the program
    • Declare the required variables.
    • Create sets to hold each files words.
    • Read the first file name from the user.
    • Read the second file name from the user.
    • Build the sets for two files.
    • Display the unique words in both files using “showUnion()” function.
    • Make a call to the function “showUnion()”.
    • Display only the words that appear in both files using “ShowIntersection()” function.
    • Make a call to the function “ShowIntersection ()”.
    • Display the words that appear in file #1 but not in file #2 using “showDifference()” function.
    • Make a call to the function “showDifference ()”.
    • Display the words that appear in only one file, but not in both the files using “showSymDiff()”.
  • Function definition for the “SetFile ()”:
  • Declare a variable “in” to hold the input.
  • Create an object for “ifstream”.
  • Open the file using “open()”.
  • Loop till “infile” reaches end of the file
    • Insert the word to the “setWord”.
  • Close the file using “close()”.
  • Function definition for the “showUnion()” to display the union of words from two sets:
    • Create a vector to hold the union.
    • Get the union of the sets using the “begin()” and “end()”.
    • Remove the unused words using “resize()” function.
    • Display the result.
  • Function definition for the “showIntersection ()” to display the intersection of words from two sets:
    • Create a vector to hold the intersection.
    • Get the intersection of the sets using the “begin()” and “end()”.
    • Remove the unused words using “resize()” function.
    • Display the result.
  • Function definition for the “showDifference ()” to show the difference of two sets:
    • Create a vector to hold the difference of two sets.
    • Get the union of the sets using the “begin()” and “end()”.
    • Remove the unused words using “resize()” function.
    • Display the result.
  • Function definition for the “showSymDiff ()” to show the symmetric difference of two sets:
    • Create a vector to hold the symmetric difference of two sets.
    • Get the union of the sets using the “begin()” and “end()”.
    • Remove the unused words using “resize()” function.
    • Display the result.

Blurred answer
Students have asked these similar questions
Phyton: Program 6: Write a program that allows the user to add data from files or by hand.  The user may add more data whenever they want.  The print also allows the user to display the data and to print the statistics.  The data is store in a list.  It’s easier if you make the list global so that other functions can access it. You should have the following functions: ·        add_from_file() – prompts the user for a file and add the data from it. ·        add_by_hand() – prompts the user to enter data until user type a negative number. ·        print_stats() – print the stats (min, max, mean, sum). You may use the built-in functions. Handling errors such as whether the input file exist is extra credit. To print a 10-column table, you can use the code below:    for i in range(len(data)):       print(f"{data[i]:3}", end="")       if (i+1)%10==0:          print()    print()   Sample run: Choose an action   1) add data from a file   2) add data by hand   3) print stats   4)…
C++: You will create a header file with implementation that performs the task. Together with the header and implementation, you create a test program whose main function demonstrates that your functions work as they should.   Two files, A and B which they  are sorted. The files contain Numbers. Based on the files, create a third file let calles it C . that file C is going to contain all the elements in sorted order from both files A and B.  This algorithm  is called a merge..
Read Data Write a function that reads in data from a file using the prototype below. The function can define and open the file, read the names and marks into the arrays and keep track of how many names there are in numElts, and then closes the file. The list of names and  marks can be found at the end of the lab and  copied into a text file.   void getNames(string names[], int marks[], int& numElts);   Display Data   Write a function to display the contents of names and marks using the prototype given below.   void displayData(const string names[], const int marks[], int numElts);   Linear Search Write the searchList function given the prototype below so that it searches for a given name. The functions returns and int which is the index of the name found. The main program will decide if -1 is returned then it will say name is not found otherwise it will write out the name and the mark for that name.   int linearSearch(const string list[], int numElts, string value);…

Chapter 17 Solutions

STARTING OUT WITH C++FROM CONTROL STRU

Ch. 17.3 - Write a statement that defines an empty vector...Ch. 17.3 - Prob. 17.12CPCh. 17.3 - Prob. 17.13CPCh. 17.3 - Write a statement that defines a vector object...Ch. 17.3 - What happens when you use an invalid index with...Ch. 17.3 - Prob. 17.16CPCh. 17.3 - If your program will be added a lot of objects to...Ch. 17.3 - Prob. 17.18CPCh. 17.3 - Prob. 17.19CPCh. 17.4 - Prob. 17.20CPCh. 17.4 - Write a statement that defines a nap named myMap....Ch. 17.4 - Prob. 17.22CPCh. 17.4 - Prob. 17.23CPCh. 17.4 - Prob. 17.24CPCh. 17.4 - Prob. 17.25CPCh. 17.4 - Prob. 17.26CPCh. 17.4 - Prob. 17.27CPCh. 17.5 - What are two differences between a set and a...Ch. 17.5 - Write a statement that defines an empty set object...Ch. 17.5 - Prob. 17.30CPCh. 17.5 - Prob. 17.31CPCh. 17.5 - Prob. 17.32CPCh. 17.5 - If you store objects of a class that you have...Ch. 17.5 - Prob. 17.34CPCh. 17.5 - Prob. 17.35CPCh. 17.6 - Prob. 17.36CPCh. 17.6 - What value will be stored in v[0] after the...Ch. 17.6 - Prob. 17.38CPCh. 17.6 - Prob. 17.39CPCh. 17.6 - Prob. 17.40CPCh. 17.6 - Prob. 17.41CPCh. 17.6 - Prob. 17.42CPCh. 17.7 - Prob. 17.43CPCh. 17.7 - Which operator must be overloaded in a class...Ch. 17.7 - Prob. 17.45CPCh. 17.7 - What is a predicate?Ch. 17.7 - Prob. 17.47CPCh. 17.7 - Prob. 17.48CPCh. 17.7 - Prob. 17.49CPCh. 17 - Prob. 1RQECh. 17 - Prob. 2RQECh. 17 - If you want to store objects of a class that you...Ch. 17 - If you want to store objects of a class that you...Ch. 17 - Prob. 5RQECh. 17 - Prob. 6RQECh. 17 - Prob. 7RQECh. 17 - If you want to store objects of a class that you...Ch. 17 - Prob. 9RQECh. 17 - Prob. 10RQECh. 17 - How does the behavior of the equal_range() member...Ch. 17 - Prob. 12RQECh. 17 - When using one of the STL algorithm function...Ch. 17 - You have written a class, and you plan to store...Ch. 17 - Prob. 15RQECh. 17 - Prob. 16RQECh. 17 - Prob. 17RQECh. 17 - Prob. 18RQECh. 17 - Prob. 19RQECh. 17 - Prob. 20RQECh. 17 - Prob. 21RQECh. 17 - A(n) ___________ container stores its data in a...Ch. 17 - _____________ are pointer-like objects used to...Ch. 17 - Prob. 24RQECh. 17 - Prob. 25RQECh. 17 - The _____ class is an associative container that...Ch. 17 - Prob. 27RQECh. 17 - Prob. 28RQECh. 17 - A _______ object is an object that can be called,...Ch. 17 - A _________ is a function or function object that...Ch. 17 - A ____________ is a predicate that takes one...Ch. 17 - A __________ is a predicate that takes two...Ch. 17 - A __________ is a compact way of creating a...Ch. 17 - T F The array class is a fixed-size container.Ch. 17 - T F The vector class is a fixed-size container.Ch. 17 - T F You use the operator to dereference an...Ch. 17 - T F You can use the ++ operator to increment an...Ch. 17 - Prob. 38RQECh. 17 - Prob. 39RQECh. 17 - T F You do not have to declare the size of a...Ch. 17 - T F A vector uses an array internally to store its...Ch. 17 - Prob. 42RQECh. 17 - T F You can store duplicate keys in a map...Ch. 17 - T F The multimap classs erase() member function...Ch. 17 - Prob. 45RQECh. 17 - Prob. 46RQECh. 17 - Prob. 47RQECh. 17 - Prob. 48RQECh. 17 - T F If two iterators denote a range of elements...Ch. 17 - T F You must sort a range of elements before...Ch. 17 - T F Any class that will be used to create function...Ch. 17 - T F Writing a lambda expression usually requires...Ch. 17 - T F You can assign a lambda expression to a...Ch. 17 - Prob. 54RQECh. 17 - Write a statement that defines an iterator that...Ch. 17 - Prob. 56RQECh. 17 - The following statement defines a vector of ints...Ch. 17 - Prob. 58RQECh. 17 - Prob. 59RQECh. 17 - The following code defines a vector and an...Ch. 17 - The following statement defines a vector of ints...Ch. 17 - Prob. 62RQECh. 17 - Prob. 63RQECh. 17 - Prob. 64RQECh. 17 - Look at the following vector definition: vectorint...Ch. 17 - Write a declaration for a class named Display. The...Ch. 17 - Write code that docs the following: Uses a lambda...Ch. 17 - // This code has an error. arrayint, 5 a; a[5] =...Ch. 17 - // This code has an error. vectorstring strv =...Ch. 17 - // This code has an error. vectorint numbers(10);...Ch. 17 - // This code has an error. vectorint numbers ={1,...Ch. 17 - Prob. 72RQECh. 17 - Prob. 73RQECh. 17 - // This code has an error. vectorint v = {6, 5, 4,...Ch. 17 - // This code has an error. auto sum = ()[int a,...Ch. 17 - Unique Words Write a program that opens a...Ch. 17 - Course Information Write a program that creates a...Ch. 17 - Prob. 3PCCh. 17 - File Encryption and Decryption Write a program...Ch. 17 - Prob. 5PCCh. 17 - Prob. 6PCCh. 17 - Prob. 7PCCh. 17 - Prob. 8PC
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education