Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java I need a method that takes in a String an expressions and checks to see

ID: 3757991 • Letter: I

Question

In Java I need a method that takes in a String an expressions and checks to see if it is valid, if it is not valid it should print the messeages below. The method should return false if the string is not valid.


Enter expression: 1 2 +
Error in expression!! No operator between operands. Also last token must be an operand.

Enter expression: 10.4
Error in expression!! Cannot accept floating point numbers.

Enter infix expression: 1 ( + 2)
Error in expression!! No operator between operand and left parentheses.

Enter infix expression: 5 – (x – 2))
Error in expression!! No matching left parentheses for a right parentheses.

Enter infix expression: 1 ** 2
Error in expression!! The * operator cannot be preceded by a * operator.

Explanation / Answer

CODE :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote