Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 3PP
Program Plan Intro
Rational Numbers
Program Plan:
Interface file “stringSet.h”:
- Include required header files.
- Define class “StringSet”.
- Declare default constructor for “StringSet” class.
- Declare constructor for “StringSet” with two arguments.
- Declare function for add a string to a set, remove a string from set, clear whole set, determine the number of strings in a set and display set.
- Declare function for overload operator “+” and “*”.
- Declare function search the string in a set.
- Declare
vector variables for strings in set.
Implementation file “stringSet.cpp”:
- Include required header files.
- Define default constructor for “StringSet” class.
- Define constructor for “StringSet” class with two arguments.
- Define function “displaySet()”.
- This function is used to display each strings in a set.
- Define function “clearSet()”.
- This function is used to clear entire set.
- Define function “findNumberOfStrings()”.
- This function is used to return the number of strings in a set.
- Define function “findString()”.
- This function is used to search a string in set.
- Define function “addString()”.
- This function is used to add a string to set.
- Define function “removeString()”.
- This function is used to remove a string from set.
- Define function for overload operator “+” and “*”.
Application file “main.cpp”:
- Include required header file.
- Define main function.
- Initializes three element in “set” array that is for set one.
- Create an object of “StringSet” class passing arguments “set” and “3”.
- Display the strings in set one by calling “displaySet” function.
- Remove a string from set one by calling the function “removeString”.
- Add a string to set one by calling the function “addString”.
- After removing and adding, display the string in set one by calling the function “displaySet”.
- By using “findNumberOfStrings()”, display the size of elements in set one.
- Then create the string array “s1” and “s3” and then call with “StringSet” class.
- Display the set two and set three strings by using “displaySet” function.
- Compute the intersection of set two and set three using overload operator “*” and then store in “StringSet” object “s4” that is for set four.
- Then compute the union of set one and set four using overload operator “+” and then store in “StringSet” object “s5” that is for set five.
- Finally clear the set four by using “clearSet()” function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
EX:[AE00]=fa50h number of ones =1111 1010 0101 0000
Physical address=4AE00h=4000h*10h+AE00h
Mov ax,4000
Mov ds,ax; DS=4000h
mov ds,4000 X
Mov ax,[AE00] ; ax=[ae00]=FA50h
Mov cx,10; 16 bit in decimal
Mov bl,0
*: Ror ax,1
Jnc **
Inc bl
**:Dec cx
Jnz *
;LSB⇒CF
Cf=1
; it jump when CF=0, will not jump when CF=1
HW1: rewrite the above example use another way
EX2: Write a piece of assembly code that can count the number of
ones in word stored at 4AE00h
Write a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question. In the student sample programs for this book, you will find a text file named 8_ball_responses.txt. The file contains 12 responses, such as “I don’t think so”, “Yes, of course!”, “I’m not sure”, and so forth. The program should read the responses from the file into a list. It should prompt the user to ask a question, then display one of the responses, randomly selected from the list. The program should repeat until the user is ready to quit.
Contents of 8_ball_responses.txt:
Yes, of course! Without a doubt, yes. You can count on it. For sure! Ask me later. I'm not sure. I can't tell you right now. I'll tell you after my nap. No way! I don't think so. Without a doubt, no. The answer is clearly NO.
(You can access the Computer Science Portal at www.pearsonhighered.com/gaddis.)
Chapter 12 Solutions
Problem Solving with C++ (9th Edition)
Ch. 12.1 - Suppose that you are defining an ADT class and...Ch. 12.1 - Which of the following files has a name that ends...Ch. 12.1 - Prob. 3STECh. 12.1 - Suppose you define a class in separate files and...Ch. 12.1 - Suppose you want to change the implementation of...Ch. 12.1 - What is the difference between an ADT you define...Ch. 12.2 - Consider the program shown in Display 12.5. Could...Ch. 12.2 - In Self-Test Exercise 7, we saw that you could not...Ch. 12.2 - Prob. 9STECh. 12.2 - Prob. 10STE
Ch. 12.2 - Consider the following function declarations from...Ch. 12.2 - Would the program in Display 12.8 behave any...Ch. 12.2 - Prob. 13STECh. 12.2 - In Display 12.7 there are two groupings for the...Ch. 12 - Add the following member function to the ADT class...Ch. 12 - Prob. 3PCh. 12 - Redo Practice Programs 2 from Chapter 11, but this...Ch. 12 - This Practice Program explores how the unnamed...Ch. 12 - Prob. 1PPCh. 12 - Redo (or do for the first time) Programming...Ch. 12 - Prob. 3PP
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
- I need help creating the network diagram and then revising it for the modified activity times.arrow_forwardActivity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.arrow_forwardGiven the following Extended-BNF grammar of the basic mathematical expressions: Show the derivation steps for the expression: ( 2 + 3 ) * 6 – 20 / ( 3 + 1 ) Draw the parsing tree of this expression. SEE IMAGEarrow_forward
- Whentheuserenters!!,themostrecentcommandinthehistoryisexecuted.In the example above, if the user entered the command: Osh> !! The ‘ls -l’ command should be executed and echoed on user’s screen. The command should also be placed in the history buffer as the next command. Whentheuserentersasingle!followedbyanintegerN,theNthcommandin the history is executed. In the example above, if the user entered the command: Osh> ! 3 The ‘ps’ command should be executed and echoed on the user’s screen. The command should also be placed in the history buffer as the next command. Error handling: The program should also manage basic error handling. For example, if there are no commands in the history, entering !! should result in a message “No commands in history.” Also, if there is no command corresponding to the number entered with the single !, the program should output "No such command in history."arrow_forwardActivity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.arrow_forward2. UNIX Shell and History Feature [20 points] This question consists of designing a C program to serve as a shell interface that accepts user commands and then executes each command in a separate process. A shell interface gives the user a prompt, after which the next command is entered. The example below illustrates the prompt osh> and the user's next command: cat prog.c. The UNIX/Linux cat command displays the contents of the file prog.c on the terminal using the UNIX/Linux cat command and your program needs to do the same. osh> cat prog.c The above can be achieved by running your shell interface as a parent process. Every time a command is entered, you create a child process by using fork(), which then executes the user's command using one of the system calls in the exec() family (as described in Chapter 3). A C program that provides the general operations of a command-line shell can be seen below. #include #include #define MAX LINE 80 /* The maximum length command */ { int…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage