Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java code To complete this code: please make a GUI calculator that works with it. Please be sure to throw an exception if a

In java code

To complete this code: please make a GUI calculator that works with it.

Please be sure to throw an exception if a user enters wrong information for example, the wrong symbol or if they only put 1 parenthesis be sure to throw an exception. There has to be equal amount of open parenthesis and closed parenthesis.

image text in transcribedimage text in transcribedimage text in transcribed

(Infix-to-Postfix Converter) Stacks are used by compilers to help in the process of evaluating expressions and generating machine-language code. In this exercise, we investigate how compilers evaluate arithmetic expressions consisting only of constants, operators and parentheses Humans generally write expressions like 3 +4 and 7/9 in which the operator (+ or/here) is written between its operands-this is called infix notation. Computers "prefer" postfix notation, in which the operator is written to the right of its two operands. The preceding infix expressions would appear in postfix notation as 3 4+and 7 9/, respectively. o evaluate a complex infix expression, a compiler would first convert the expression t fix notation and evaluate the postfix version. Each of these algorithms requires only a single left-to- right pass of the expression. Each algorithm uses a stack object in support of its e stack for a different purpose. Write class InfixToPostfixConverter to convert an ordinary infix arithmetic expression (Check to make sure that a valid expression is entered) (6 +2) * 5-8/4 to a postfix expression. The postfix version (no parentheses are needed) of the this infix expression is 62+5* 84/ The program should read the expression into StringBuffer infix and use a stack class implemented to help create the postfix expression in StringBuffer postfix. The algorithm for creating a postfix expression is as follows: a) Push a left parenthesis " onto the stack. b) Append a right parenthesis')'to the end of infix c) While the stack is not empty, read infix from left to right and do the following: If the current character in infix is a digit, append it to postfix. If the current character in infix is a left parenthesis, push it onto the stack. If the current character in infix is an operator: Pop (Infix-to-Postfix Converter) Stacks are used by compilers to help in the process of evaluating expressions and generating machine-language code. In this exercise, we investigate how compilers evaluate arithmetic expressions consisting only of constants, operators and parentheses Humans generally write expressions like 3 +4 and 7/9 in which the operator (+ or/here) is written between its operands-this is called infix notation. Computers "prefer" postfix notation, in which the operator is written to the right of its two operands. The preceding infix expressions would appear in postfix notation as 3 4+and 7 9/, respectively. o evaluate a complex infix expression, a compiler would first convert the expression t fix notation and evaluate the postfix version. Each of these algorithms requires only a single left-to- right pass of the expression. Each algorithm uses a stack object in support of its e stack for a different purpose. Write class InfixToPostfixConverter to convert an ordinary infix arithmetic expression (Check to make sure that a valid expression is entered) (6 +2) * 5-8/4 to a postfix expression. The postfix version (no parentheses are needed) of the this infix expression is 62+5* 84/ The program should read the expression into StringBuffer infix and use a stack class implemented to help create the postfix expression in StringBuffer postfix. The algorithm for creating a postfix expression is as follows: a) Push a left parenthesis " onto the stack. b) Append a right parenthesis')'to the end of infix c) While the stack is not empty, read infix from left to right and do the following: If the current character in infix is a digit, append it to postfix. If the current character in infix is a left parenthesis, push it onto the stack. If the current character in infix is an operator: Pop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago