In Java I need a method that takes in a String an expressions and checks to see
ID: 3757986 • 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 :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.