Home / Expert Answers / Computer Science / write-a-complete-c-program-named-hw1-cpp-that-can-perform-adding-subtracting-dividing-and-multi-pa208

(Solved): Write a complete C++ program named hw1.cpp that can perform adding, subtracting, dividing, and multi ...



Write a complete C++ program named hw1.cpp that can perform adding, subtracting, dividing, and multiplying integers:

  1. Declare two integers and a string for two operands and an operator respectively.

  2. Prompt user to enter the arithmetic expression. Separate operand and operator by space.

  3. Allowed operators for user:

    1. addition: +

    2. subtraction: -

    3. multiplication: x, X, or *

    4. division: /

  4. Read the arithmetic expression given by user and save it in variables

  5. Print the result of the arithmetic expression given by user. For division, provide quotient and remainder.

  6. Print “Not a valid arithmetic expression” when user does not use a valid operator

  7. sample run:

[swu@venus cs111]\$./a.out
Enter the arithmetic expression: \( 5+2 \)
\( 5+2=7 \)
[swu@venus cs111]\$. /a.out
Enter the arith

[swu@venus cs111]\$./a.out Enter the arithmetic expression: \( 5+2 \) \( 5+2=7 \) [swu@venus cs111]\$. /a.out Enter the arithmetic expression: \( 5-2 \) \( 5-2=3 \) [swu@venus cs111]\$./a.out Enter the arithmetic expression: \( 5 \times 2 \) \( 5 \times 2=10 \) \( {[ \) swu@venus cs111]\$. /a.out \( } \) Enter the arithmetic expression: \( 5 \times 2 \) \( 5 \times 2=10 \) [swu@venus cs111]\$. / a.out Enter the arithmetic expression: \( 5 * 2 \) \( 5 * 2=10 \) [swu@venus cs111]\$. / a.out Enter the arithmetic expression: \( 5 / 2 \) \( 5 / 2 \) / Quotient is 2 and remainder is 1 [swu@venus cs111]\$ . /a.out Enter the arithmetic expression: \( 5+=2 \) Not a valid arithmetic expression.


We have an Answer from Expert

View Expert Answer

Expert Answer


Steps: 1)Declare two variables and a string for the two operands and for the operand. 2)for the entered operand "+" , we need to perform arithmetic su
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe