# 8.9 Expression Evaluation Background A fully parenthesized arithmetic.docx

• No School
• AA 1
• 4

This preview shows page 1 - 3 out of 4 pages.

Subscribe to view the full document.

8.9 Expression Evaluation Background A fully parenthesized arithmetic expression is either a number or set of numbers an operations as follows (1 + ((2 + 3) * 4)) Expressions like 1 + 2 * 3, which rely on precedence, are not allowed. Expressions like (1 + 2 * 3) are also not allowed, each binary operation must be enclosed in parentheses like (1 + (2* 3)). Problem Statement Complete the method double evaluate(String expr). The method should return a double value for fully parenthesized statements. This means every (must be closed by). They must be closed in the correct order, and there cannot be extra ) that do not close anything. Likewise, no ( should be left open. See this video to understand stacks with Dijkstra's two stack algorithm for arithmetic expression evaluation. A sample main function is provided so that you may test your code on sample inputs. Inputs can be provided in the box below your code, please format your input as follows: Example input (1 + 2) (2 + (4 * 3)) Requirements Each operation must be enclosed in parentheses. You are

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes