STARTING OUT W/C++,...(LL)-W/ACCESS
9th Edition
ISBN: 9780134596174
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 19, Problem 7PC
Program Plan Intro
Dynamic MathStack
Program Plan:
MathStack.h:
- Include required header files
- Declare a class named “MathStack”. Inside the class,
- Inside “public” access specifier,
- Declare functions “add ()”, “sub ()”, “mult ()”, “div ()”, “addAll ()”, and “multAll ()”.
- Inside “public” access specifier,
MathStack.cpp:
- Include required header files.
- Give function definition to add elements “add()”.
- Declare required variables “number”, and “sum_Value”.
- Call the function “pop()”.
- Add the elements.
- Push the value into the stack using the function “push()”.
- Give function definition to subtract elements “sub()”.
- Declare required variables “number”, and “diff_Value”.
- Call the function “pop()”.
- Subtract the elements.
- Push the value into the stack using the function “push()”.
- Give function definition to multiply elements “mult()”.
- Declare required variables “number”, and “prod_Value”.
- Call the function “pop()”.
- Multiply the elements.
- Push the value into the stack using the function “push ()”.
- Give function definition to divide elements “div()”.
- Declare required variables “number”, and “quo_Value”.
- Call the function “pop()”.
- Divide the elements.
- Push the value into the stack using the function “push()”.
- Give function definition to add all the elements “addAll()”.
- Declare required variables “number”, and “sum_Value”.
- Call the function “pop()”.
- Add all the elements.
- Push the value into the stack using the function “push()”.
- Give function definition to multiply all the elements “multAll()”.
- Declare required variables “number”, and “prod_Value”.
- Call the function “pop()”.
- Multiply all the elements.
- Push the value into the stack using the function “push()”.
IntStack.h:
- Include required files.
- Declare a class named “IntStack”. Inside the class,
- Inside “protected” access specifier,
- Declare a pointer named “stackArray”.
- Declare variables “stackSize” and “top”.
- Inside “public” access specifier,
- Declare constructor and destructor.
- Give function declarations.
- Inside “protected” access specifier,
IntStack.cpp:
- Declare required header files.
- Give definition for constructor,
- Create a stack array and assign the size
- Give definition for destructor,
- Delete the array and assign it to null
- Give function definition to push elements “push()”
- Check if the stack is full using the function “isFull()”,
- If the condition is true then, print “The stack is full”.
- If the condition is not true then,
- Increment the variable.
- Assign “num” to the top position.
- Check if the stack is full using the function “isFull()”,
- Give function definition to pop elements “pop ()”,
- Check if the stack is empty using the function “isEmpty()”.
- If the condition is true then, print “The stack is empty”.
- Assign top element to the variable.
- Decrement the variable.
- If the condition is true then, print “The stack is empty”.
- Check if the stack is empty using the function “isEmpty()”.
- Give function definition to check if the stack is full “isFull()”.
- Assign “false” to the Boolean variable “status”.
- Check if the stack size if full.
- Assign true
- Return the Boolean variable “status”.
- Give function definition to check if the stack is empty “isEmpty()”.
- Assign “false” to the Boolean variable
- Check if top is empty
- Assign true.
- Return the variable
Main.cpp:
- Include required header files.
- Inside “main ()” function,
- Declare constant variables “STACKSIZE”, “ADDSIZE”, and “MULTSIZE”.
- Create three stacks “stack”, “addAllStack”, and “multAllStack”.
- Declare a variable “popVar”.
- Push two elements to perform add operation.
- Call the function “add()”.
- Display the element.
- Push two elements to perform multiplication operation.
- Call the function “mult()”.
- Display the element.
- Push two elements to perform division operation.
- Call the function “div()”.
- Display the element.
- Push two elements to perform subtraction operation.
- Call the function “sub()”.
- Display the element.
- Push four elements to perform addAll operation.
- Call the function “addAll()”.
- Display the element.
- Push six elements to perform multAll operation.
- Call the function “multAll()”.
- Display the element.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q2/find the transfer function C/R for the system shown in the figure
Re
ད
Please original work
select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project
Please cite in text references and add weblinks
Please original work
What topic would be related to architectures or infrastructures.
How you would implement your chosen topic in a data warehouse project.
Please cite in text references and add weblinks
Chapter 19 Solutions
STARTING OUT W/C++,...(LL)-W/ACCESS
Ch. 19.1 - Describe what LIFO means.Ch. 19.1 - What is the difference between static and dynamic...Ch. 19.1 - What are the two primary stack operations?...Ch. 19.1 - What STL types does the STL stack container adapt?Ch. 19 - Prob. 1RQECh. 19 - Prob. 2RQECh. 19 - What is the difference between a static stack and...Ch. 19 - Prob. 4RQECh. 19 - Prob. 5RQECh. 19 - The STL stack is considered a container adapter....
Ch. 19 - What types may the STL stack be based on? By...Ch. 19 - Prob. 8RQECh. 19 - Prob. 9RQECh. 19 - Prob. 10RQECh. 19 - Prob. 11RQECh. 19 - Prob. 12RQECh. 19 - Prob. 13RQECh. 19 - Prob. 14RQECh. 19 - Prob. 15RQECh. 19 - Prob. 16RQECh. 19 - The STL stack container is an adapter for the...Ch. 19 - Prob. 18RQECh. 19 - Prob. 19RQECh. 19 - Prob. 20RQECh. 19 - Prob. 21RQECh. 19 - Prob. 22RQECh. 19 - Prob. 23RQECh. 19 - Prob. 24RQECh. 19 - Prob. 25RQECh. 19 - Prob. 26RQECh. 19 - Write two different code segments that may be used...Ch. 19 - Prob. 28RQECh. 19 - Prob. 29RQECh. 19 - Prob. 30RQECh. 19 - Prob. 31RQECh. 19 - Prob. 32RQECh. 19 - Prob. 1PCCh. 19 - Prob. 2PCCh. 19 - Prob. 3PCCh. 19 - Prob. 4PCCh. 19 - Prob. 5PCCh. 19 - Dynamic String Stack Design a class that stores...Ch. 19 - Prob. 7PCCh. 19 - Prob. 8PCCh. 19 - Prob. 9PCCh. 19 - Prob. 10PCCh. 19 - Prob. 11PCCh. 19 - Inventory Bin Stack Design an inventory class that...Ch. 19 - Prob. 13PCCh. 19 - Prob. 14PCCh. 19 - Prob. 15PC
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
- What is cloud computing and why do we use it? Give one of your friends with your answer.arrow_forwardWhat are triggers and how do you invoke them on demand? Give one reference with your answer.arrow_forwardDiscuss with appropriate examples the types of relationships in a database. Give one reference with your answer.arrow_forward
- Determine the velocity error constant (k,) for the system shown. + R(s)- K G(s) where: K=1.6 A(s+B) G(s) = as²+bs C(s) where: A 14, B =3, a =6. and b =10arrow_forward• Solve the problem (pls refer to the inserted image)arrow_forwardWrite .php file that saves car booking and displays feedback. There are 2 buttons, which are <Book it> <Select a date>. <Select a date> button gets an input from the user, start date and an end date. Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, it books cars for specific dates, with bookings saved. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. In the booking.json file, if the Car ID and start date and end date matches, it fails Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert).arrow_forward
- Write .php file with the html that saves car booking and displays feedback. Booking should be in the .json file which contains all the bookings, and have the following information: Start Date. End Date. User Email. Car ID. There are 2 buttons, which are <Book it> <Select a date> Book it button can be pressed only if the start date and ending date are chosen by the user. If successful, book cars for specific dates, with bookings saved. If the car is already booked for the selected period, a failure message should be displayed, along with a button to return to the homepage. Use AJAX: Save bookings and display feedback without page refresh, using a custom modal (not alert). And then add an additional feature that only free dates are selectable (e.g., calendar view).arrow_forward• Solve the problem (pls refer to the inserted image) and create line graph.arrow_forwardwho started the world wide webarrow_forward
- Question No 1: (Topic: Systems for collaboration and social business The information systems function in business) How does Porter's competitive forces model help companies develop competitive strategies using information systems? • List and describe four competitive strategies enabled by information systems that firms can pursue. • Describe how information systems can support each of these competitive strategies and give examples.arrow_forwardData communıcatıon digital data is transmitted via analog ASK and PSK are used together to increase the number of bits transmitted a)For m=8,suggest a solution and define signal elements , and then draw signals for the following sent data data = 0 1 0 1 1 0 0 0 1 0 1 1arrow_forwardDatacommunicationData = 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0a) how many bıts can be detected and corrected by this coding why prove?b)what wıll be the decision of the reciever if it recieve the following codewords why?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ 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 Ptr
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher: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
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