Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 13, Problem 10PP
Program Plan Intro
Creation of program to display result of computation of Reverse polish Notation
Program Plan:
- Define a file “Stack.h” to declare operation and methods in stack.
- Define a structure “StckNde” that contains data and link to next node as members.
- Define a class “Stack” to define methods and prototypes.
- Define function prototypes for methods in program.
- Define a file “Stack.cpp” to define operations and methods in stack.
- Define a constructor “Stack()” to create an empty stack.
- Define a destructor “~Stack()” to destroy a stack.
- Define a method “empty()” to check whether stack is empty.
- Define a method “pop()” to remove top element of stack.
- Define a method “datatyeCon()” to display error if stack is empty.
- Define a method “operator=()” to define operation for “=” operator.
- Define a method “operator==()” to define operation for “==” operator.
- Define a file “Main.cpp” to call methods in stack and perform all computations.
- Declare variables required for the program.
- Get expression from user.
- Check for operators and operands.
- Define a switch case to perform different computations in expression.
- Display result of operation.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design and implement an application that reads a sentence fromthe user and prints the sentence with the characters of each wordbackwards. Use a stack to reverse the characters of each word.8. Pop the infix expression off the stack and print it.
Code with comments and output screenshot is must for an Upvote
Create a Java function that uses a stack and no arithmetic to compare the number of 0's and 1's in a string. If # of 0's is greater, return -1. If # of 1's is greater, return 1. If equal, return 0.
Try a spatuladef pancake_scramble(text):Analogous to flipping a stack of pancakes by sticking a spatula inside the stack and flipping over the stack of pancakes resting on top of that spatula, a pancake flip of order k performed for the text string reverses the prefix of first k characters and keeps the rest of the string as it were. For example, the pancake flip of order 2 performed on the string 'ilkka' would produce the string 'likka'. The pancake flip of order 3 performed on the same string would produce 'klika'.A pancake scramble, as defined in the excellent Wolfram Challenges programming problems site, consists of the sequence of pancake flips of order 2, 3, ... , n performed in this exact sequence for the given n-character text string. For example, the pancake scramble done to the string 'ilkka' would step through the intermediate results 'likka', 'kilka', 'klika' and 'akilk'. This function should compute and return the pancake scramble of its parameter text string.
text…
Chapter 13 Solutions
Problem Solving with C++ (10th Edition)
Ch. 13.1 - Suppose your program contains the following type...Ch. 13.1 - Suppose that your program contains the type...Ch. 13.1 - Prob. 3STECh. 13.1 - Prob. 4STECh. 13.1 - Prob. 5STECh. 13.1 - Prob. 6STECh. 13.1 - Prob. 7STECh. 13.1 - Suppose your program contains type definitions and...Ch. 13.1 - Prob. 9STECh. 13.2 - Prob. 10STE
Ch. 13.2 - Prob. 11STECh. 13.2 - Prob. 12STECh. 13.2 - Prob. 13STECh. 13 - The following program creates a linked list with...Ch. 13 - Re-do Practice Program 1, but instead of a struct,...Ch. 13 - Write a void function that takes a linked list of...Ch. 13 - Write a function called mergeLists that takes two...Ch. 13 - In this project you will redo Programming Project...Ch. 13 - A harder version of Programming Project 4 would be...Ch. 13 - Prob. 6PPCh. 13 - Prob. 8PPCh. 13 - Prob. 9PPCh. 13 - Prob. 10PP
Knowledge Booster
Similar questions
- In C++arrow_forwardConsider the following statements: linkedStackType<int> stack; linkedQueueType<int> queue; int num; Suppose the input is 28 30 15 11 10 -9 21 8 -3 33 17 14 Write a C++ code that processes these numbers as follows: If the number is an even number, it is pushed onto the stack. If the number is odd and divisible by 3, it is added into the queue; otherwise the top element, if any, of the stack is removed and the square of the number is added onto the stack. After processing these numbers, what is stored in stack and queue?arrow_forwardDesign a C++ program which reads any number of integers in a linked list until "-1" is entered. Then your program must display all numbers between the smallest and largest numbers in this list. Enter your list: 14 33 28 7 16 22 38 10 39 40 36 -1 Result: 7->16->22->38->10->39->40 Enter your list: 30 34 4 29 27 19 2 21 23 33 3 4 7 21 24 14 5-1 Result: 34->4->29->27->19->2->21->23->33->3arrow_forward
- in java pls and thank you!arrow_forwardJava : Write the Java code segment that uses a stack to determine if a string is a palindrome (assume all that blanks have been removed). A palindrome contains the same characters forwards as backwards, for example level is a palindrome. Your solution must use only a stack, you MUST process the string from left to right, and are allowed to go through the string only once. You must use an efficient algorithm. Use : ArrayStack class given below: /** * Creates an empty stack using the default capacity. */ public ArrayStack() { this(DEFAULT_CAPACITY); } /** * Creates an empty stack using the specified capacity. * @param initialCapacity the initial size of the array */ public ArrayStack(int initialCapacity) { top = 0; stack = (T[])(new Object[initialCapacity]); }arrow_forward2 DO NOT COPY FROM OTHER WEBSITES Correct and detailed answer will be Upvoted else downvoted. Thank you!arrow_forward
- The destination of a function's return value may be represented as a sequence of instructions. When making modifications to the stack, keep in mind that they must not prevent the method from returning to its caller.arrow_forwardL.A stack contain 5 elements. Ihe first element added to the stack is A, the third, B aned the last C. Let the untnan eements be X. Braw the Structure of the stack, Araws the stacd afte paqeuming the pollowing a. fop, Pop push C12) b. Top Tupc), POPO c Push 3arrow_forwardCreate a Java Program of a Simple or Singly Linked List with the following specifications: - Number of List and data in each node are user input- Display the following options and create the appropriate program for each:1 - CREATE NODE LIST2 - INSERT NODE AT START3 - INSERT NODE AT END4 - DELETE NODE AT START5 - DELETE NODE AT END6 - DISPLAY7 - EXIT (The program will stop if the user choose the EXIT option)arrow_forward
- Given a string containing opening and closing braces, check if it represents a balanced expression or not using the stack. Example: [ () {()} {{()}} ] it should give no error Example: { () (}}] , [(}] it should give an errorarrow_forwardTask:implement a function that reverses a list of elements by pushing them onto a stack in one order and writing them back to the list in reversed order P.S:Answer must be in pythonarrow_forwardstacks and queues. program must be able to handle all test cases without causing an exception Note that this problem does not require recursion to solve (though you can use that if you wish).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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning