MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 12.13E
Program Plan Intro
Program Plan:
- Use stack implementation as provided in figure 12.08 of the book.
- Define a function calculate as mentioned. Inside this function use switch statement to evaluate value of operands as per operator.
- Define function evaluatePostfix() that take one argument exp which a pointer of type char. Inside this function create a stack pointer.
- Further scan character of expression in exp pointer character by character and then use push, pop and calculate functions to evaluate the expression and return final value.
- Define main function. Inside main read postfix expression from user and call evaluatePostfix function using the read expression.
Program Description:
The followingprograms evaluate the postfix expression using stacks.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Complete my C++ program:
Instructions:
You have to continue on implementing your Array List namely the following functions:
Example ArrayList: [10, 30, 40, 50]
void addAt(int num, int pos)
This method will add the integer num to the posth position of the list.
Performing addAt(20, 2) in the example list will add 20 at the 2nd position and the array will now look like this: [10, 20, 30, 40, 50]
When the value of pos is greater than the size + 1 or less than one, output "Position value invalid"
void removeAt(int pos)
Removes the number in the posth position of the list.
Performing removeAt(3) in the example list will remove the 3rd element of the list and the updated array will be: [10, 30, 50]
When the value of pos is greater than the size or less than one, output "Position value invalid"
void removeAll(int num)
Removes all instances of num in the array list.
In this array [10, 10, 20, 30, 10], performing removeAll(10) will remove all 10's and the list will look like this: [20,…
(Random sentences and story writer) Write an app that uses random-number generation to create sentences. Use four arrays of strings, called article, noun, verb andprepostion. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article, noun.As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the sentence is output, it should start witha capital letter and end with a period. The program should generate 10 sentences and output them to a text box. The arrays should be filled as follows:The article array should contain the articles "the", "a", "one", "some" and "any";The noun array should contain the nouns "boy", "girl", "dog", "town", "car";The verb array should contain the past tense verbs "drove", "jumped", "ran", "walked" and "skipped";The preposition array should contain the preposotions "to", "from", "over", "under" and "on";
(Sort three numbers) Write the following function to display three numbers in increasing order:
def displaySortedNumbers(num1, num2, num3):
Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order. Here are some sample runs:
Chapter 12 Solutions
MYPROGRAMMINGLAB WITH PEARSON ETEXT
Ch. 12 - Prob. 12.6ECh. 12 - (Merging Ordered Lists) Write a program that...Ch. 12 - Prob. 12.8ECh. 12 - (Creating a Linked List, Then Reversing Its...Ch. 12 - Prob. 12.10ECh. 12 - Prob. 12.11ECh. 12 - Prob. 12.12ECh. 12 - Prob. 12.13ECh. 12 - Prob. 12.14ECh. 12 - (Supermarket Simulation) Write a program that...
Knowledge Booster
Similar questions
- Language: C/C++ Q.1 - Write an algorithm that takes an array of characters, with only the characters 1, 2 and only two occurrences of the character 0, and the size of the array that has filled (valid) characters. This algorithm must check that the string that is stored is of the form x0y0x, where x is the inverse of y. (if x= "12221122", y="22112221"). The algorithm must use the Stack functions (create, pop, push, destroy, isempty) Q.2 - Write an algorithm for the Pune operation, which punishes an element on a stack by pushing it back n positions. Assume that the stack is implemented as a simply chained linear list. Pune (Pilha *p, int n); Q.3 - Write an algorithm that punishes the first element of a row represented in a circular vector, taking it out of the first position and placing it in the middle of the row.P.S: It cannot perform calls to the Insert and Remove function from the queue, the algorithm must perform the operation only with vector manipulation. void…arrow_forwardusing c++ programming ::::: 16. (Pick 5 Lotto) Write a program to simulate a pick-5 lottery game. Your program should generate and store 5 distinct numbers between 1 and 9 (inclusive) into an array. The program prompts the user to enter five distinctbetween 1 and 9 and stores the number into another array. The programthen compares and determines whether the two arrays are identical. If thetwo arrays are identical, then the user wins the game; otherwise the program outputs the number of matching digits and their position in the array.Your program must contain a function that randomly generates thepick-5 lottery numbers. Also, in your program, include the functionsequential search to determine if a lottery number generated hasalready been generated.arrow_forwardIn C++arrow_forward
- please code in python Forbidden concepts: arrays/lists (data structures), recursion, custom classes You have been asked to take a small icon that appears on the screen of a smart telephone and scale it up so it looks bigger on a regular computer screen.The icon will be encoded as characters (x and *) in a 3 x 3 grid as follows: (refer image1 ) Write a program that accepts a positive integer scaling factor and outputs the scaled icon. A scaling factor of k means that each character is replaced by a k X k grid consisting only of that character. Input Specification:The input will be an integer such that 0 < k ≤ 10. Output Specification:The output will be 3k lines, which represent each individual line scaled by a factor of k and repeated k times. A line is scaled by a factor of k by replacing each character in the line with k copies of the character. [refer image2]arrow_forwardTtyyyffarrow_forwardQ2: Write a C++ function (call it index_max) that finds the maximum number in a 1-D array of floats, that is passed to the function, and returns the max number and its index. For example, if you pass [5.1, 6, 8.5, 9, 5.6, 2.7] to the function, you obtain 9 and 3. Write a C++ program and test your function. Take the following note into consideration when writing your program: • The function should prevent changing the elements of the passed array.arrow_forward
- Complete/Modify the code satisfying the following: (put comments pls) in C++, pls put COMMENTS in the code 1. Create a 10x10 matrix using rand function to fill the said matrix with random numbers 2. Print all the numbers in matrix form 3. Ask the user the following options OPTIONS: A. Total sum, average, median per row B. Total sum, average, median per column C. Display the same matrix but all ODD numbers are replaced with "-" (minus sign) D. Display the same matrix but all EVEn numbers are replaced with "+" (plus sign E. Display the same matrix but all PRIME numbers are replaced with "*" (asterisksign) F. Display the whole matrix with every row in ascending order G. Display the whole matrix with every row in descending order H. Display the whole matrix with every column in ascending order I. Display the whole matrix with every cloumn in descending order J. Generate new set of random numbers Q. Close the program After asking what option to display, Display again the previous numbers…arrow_forward[ ] [] power In the cell below, you are to write a function "power(list)" that takes in a list as its input, and then returns the power set of that list. You may assume that the input will not have any duplicates (i.e., it's a set). After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (power ( ["A", "B"]), power ( ["A", "B", "C"])) + Code + Markdown This should return [[], ["A"], ["B"], ["A", "B"]] [[], ["A"], ["B"], ["C"], ["A", "B"], ["A", "C"], ["B", "C"], ["A", "B", "C"]] (the order in which the 'sets' appear does not matter, just that they are all there) Python Pythonarrow_forwardComplete/Modify the code satisfying the following: (put comments pls) in C++, pls put comments in the code 1. Create a 10x10 matrix using rand function to fill the said matrix with random numbers 2. Print all the numbers in matrix form 3. Ask the user the following options here are the options A. Sum per row B. Sum per column C. Display all ODD numbers horizontally D. Display all EVEN numbers horizontally E. Display all PRIME numbers horizontally F. Generate new set of random numbers G. Close the program After asking what option to display, Display again the previous numbers entered and the same options. Here's the code: #include<stdio.h>#include<math.h> main(){ char rep; rep = 'y'; while(rep=='y'||rep =='Y') { int cntr01=1,xsum=0,numrow,numcol; char option; int x[3][3]; //creates --> x[0][0],x[0][1],x[0][2] //creates --> x[1][0],x[1][1],x[1][2] //creates --> x[2][0],x[2][1],x[2][2] //cntr01++ <-->…arrow_forward
- 4. CodeW X For func X C Solved b Answer x+ https://codeworkou... ... [+) CodeWorkout X271: Recursion Programming Exercises: Minimum of array For function recursiveMin, write the missing part of the recursive call. This function should return the minimum element in an array of integers. You should assume that recursiveMin is initially called with startIndex = 0. Examples: recursiveMin({2, 4, 8}, 0) -> 2 Your Answer: 1 public int recursiveMin(int numbers[], int startIndex) { numbers.length - 1) { if (startIndex 2. return numbers[startIndex]; } else { return Math. min(numbers[startIndex], >); 5. { 1:11 AM 50°F Clear 12/4/2021arrow_forward(Algebra: perfect square ) Write a program that prompts the user to enter an integer m and find the smallest integer n such that m * n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m = 90, store the factors 2, 3, 3, 5 in an array list. 2 and 5 appear an odd number of times in the array list. So, n is 10.) Sample Run 1 Enter an integer m: 1500 The smallest number n for m x n to be a perfect square is 15 m x n is 22500 Sample Run 2 Enter an integer m: 63 The smallest number n for m x n to be a perfect square is 7 m x n is 441 Class Name: Exercise11_17 Answer is : import java.util.Scanner; public class Squares { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //instantiation of Scanner that will take inputs from the keyboard //the try catch block below is for trapping error with the input try {…arrow_forward(Sum elements row by row) write a method that returns the sum of all the elements in a specified row in a matrix using the following header: public static double sumRow(double [][] m, int rowIndex) Write a test program that reads a 3-by-4 matrix and displays the sum of each row here is a sample run.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education