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

This question is worth 4500 points, meaning I will give 1500 from this question

ID: 644386 • Letter: T

Question

This question is worth 4500 points, meaning I will give 1500 from this question and 1500 for each of these two links:

http://www.chegg.com/homework-help/questions-and-answers/c-programming-exercise-implement-command-line-calculator-allows-user-enter-expression-cont-q6873561

http://www.chegg.com/homework-help/questions-and-answers/c-programming-exercise-implement-command-line-calculator-allows-user-enter-expression-cont-q6873561

The two links contains the same question. This means that my question is posted three times.

C++ Programming Exercise:

Implement a command-line calculator that allows the user to enter an expression containing numbers, variables, brackets, and operators. The calculator will also allow assignments to a variable. After the user enters the expression the program will evaluate it and display the value. If the expression is part of an assignment its value will be also be stored in the variable. The operators are +, -, *, /, % and ^ (exponentiation). (These are all binary operators.) % should be applicable to floating point numbers and work like it does in Java. There are three types of bracket: parentheses ( ( ) ) , square brackets ( [ ] ) and braces ( {} ). A variable may be any single lowercase letter. (Uninitialized variables can have any value.) The calculator will loop until the user enters a blank line. Here is a sample run below:

> 3 + 4.5

7.5

> a = 6*2/5

2.4

> b = a+1

3.4

> b

3.4

> c = b^2

11.56

> a * {b

Explanation / Answer

Here's how I'd do it:

Note that the Scanner assumes there is whitespace before and after the operator.

Example output:

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