
Write an interactive java program for evaluating postfix expressions. The program will allow the user to enter a postfix expression from the keyboard. Assume the expression is entered correctly. Output to the screen the stack evaluation (showing the stack) after each step and final expression value. Finally, promptthe user if he/she wishes to perform another calculation or quit the program. Check case. The program must use a stack data structure.
Refer to the sample output below.
Sample Run:Enter a postfix expression: 4 5 2 * +
Stack Contents: After push operation: 4
After push operation: 4 5
After push operation: 4 5 2
After * operation: 4 10
After + operation: 14
Final Value: 14
Enter another expression (Y/N)? y
Enter an infix expression: 5 7 + 6 2 - *
Stack Contents:After push operation: 5
After push operation: 5 7
After + operation: 12
After push operation: 12 6
After push operation: 12 6 2
After - operation: 12 4
After * operation: 48
Final Value: 48
Enter another expression (Y/N)? N

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images

- Use stack as a data structure in creating a program that enable to reversed the inputstring.Create a java program that asks a user to input student’s full name and reverses the string.The program should be able to print how the string is reversed and display the reversed string. The program should display one by one on how to reverse the string and then display the final output of the reversed string.arrow_forwardComplete the missing code then compile, debug and test your program using the command lines below: c++ -o project1 project1.cpp <enter> ./project1 n m k <enter> Where n is the size of the stack, m is the modular of the real part and imagination part of a random complex number, and k is the number of elements displayed per line. In the main function, you need to Get the values n, m, and k from the command line. Declare a complex number stack of size n, generate n random complex numbers and push them into the stack. Meantime display all these numbers, k numbers per line. Display all elements of the stack, k elements per line. Create two random complex numbers c1 and c2, display c1, c2 and the results of the addition c1+c2, the subtraction c1-c2, the multiplication c1*c2, and the division c1/c2. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; class Complex {…arrow_forwardUsing c++ Contact list: Binary Search A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use binary search. Modify the algorithm to output the count of how many comparisons using == with the contactName were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Frank 867-5309 Joe…arrow_forward
- in c++ please paste working code. the program should Input- Julia Lucas Mia -1 With an expected output of- Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Juliaarrow_forwardProgram definition: Write a program that simulates the game “hangman”. a. In the game of hangman, have a user enter a word for “another” player to guess. b. After the word to guess is entered, clear the screen and present a list of blanks or underscores representing unguessed letters of the hidden word. c. Have the user guess a letter in the word. If the letter is in the word, display the letter instead of the blank or underscore and display the remaining blanks or underscores for the unguessed letters, all in the proper position. d. If a previously guessed letter is repeated, whether in the word or not, another try is allowed without penalty. If a guess is incorrect, the game state progresses toward being “hung”. e. There are 8 bad guesses allowed before the game is lost. f. The game will progress through the states of PLATORM, HEAD, BODY, LEFT_ARM, RIGHT_ARM, LEFT_LEG, RIGHT_LEG, and HUNG. Use an ENUM to represent the game states listed. g. Use a linked list to…arrow_forwardNo explicit loops must be used. In C# Suppose variable nums contains a list of integers.List«Integer> nums = Arrays.asList(1, 1, 2, 3, 4, 1, 3, 2, 4, 3, 3, 1);var nums = new List<int> { 1, 1, 2, 3, 4, 1, 3, 2, 4, 3, 3, 1 }; // C#Using Java Stream API *or* LINQ, write a short code that prints the following.For each section indicate the platform (whether the solution is given in Java orC# ILINQ).A) Print all numbers.B) Print the sum() of the numbers.C) count how many times number '1' appears in the list.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





