Can you help me a C++ Program to do the following: Create a program that reads a simple arithmetic expression and evaluates it. More precisely, the program reads from the user a line of text that’s supposed to contain two numbers separated by an arithmetic operator, as in 35.6 + 12 The program then prints back the expression and its value, as in 35.6 + 12 = 47.6

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

Can you help me a C++ Program to do the following:

Create a program that reads a simple arithmetic expression and
evaluates it. More precisely, the program reads from the user a line of
text that’s supposed to contain two numbers separated by an arithmetic
operator, as in
35.6 + 12
The program then prints back the expression and its value, as in
35.6 + 12 = 47.6
The program should verify that the input line contains two numbers, one
operator and nothing else. There can be whitespace before the first number, after the second number and between each number and the operator.
The operator can be either +, −, * or /. In case of an error, the program
should print Invalid expression and quit.
When the program prints the expression, there should be no whitespace
before the first number and there should be exactly one blank space before
and after the operator and the equal sign.
Use string streams.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr