Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to write a program that writes an RPN equation and calculates the problem in Java. I am not allowed to use import.java.util.Stack.

I am trying to write a program that writes an RPN equation and calculates the problem in Java. I am not allowed to use import.java.util.Stack. I need to write a replaceAll and Split method. image text in transcribed
image text in transcribed
You are to write a program that allows the user to type in a mathematical formula at the keyboard and produces the answer on the screen. The formula will be typed in INFIX notation and will include only positive integers for the numbers. The operators that are acceptable are the following: + (plus), - (minus), (multiply),/ (divide), and (power). Parenthesis are also allowed. You should allow the user to type in the equation of his/her choice and then display the answer on the screen. Display a real answer. (for example: 3/2-1.5, NOT 1) ALSO DISPLAY THE POST-FIX EQUATION ON THE SCREEN The normal rules of mathematics apply (parenthesis have the highest precedence followed by theA, followed by * and /, followed by - and +). Do not allow the program to bomb and warn the user if the equation is wrong. For example: 2+43/*12 cannot be calculated because there are too many operators. When I test the program, I will only type positive integers as input and I will type correct operations. Hints: You should treat the equation as a queue of tokens and read the tokens from the queue one at a time. Convert the INFIX equation to a POSTFIX equation. Then resolve the POSTFIX equation. Sample equations 12 + (2 4 /5 43 3 4 2 34 9 2 4+34 3 Postfix 12 2 4 5+ 43 3 4 2 34 +9 - 2 4 34 +3- Example of program running: Enter an equation: 12+ (6-4 Answer: 14 (1+1) / 2

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_2

Step: 3

blur-text-image_3

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What analyses could you do to evaluate these rules?

Answered: 1 week ago