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

This has to be a C++ program CS 317 Caleulator Program write a program to input

ID: 3727743 • Letter: T

Question

This has to be a C++ program CS 317 Caleulator Program write a program to input three values, two floats and an operator print out what were read and the operators to handle are +,-(equal to) and (x3 is resulting evaluation. The to raised to the third power). The floats are one or more digits in length. Read a float, char, float for input. cin >vl>opchar 2 You must use a 'switch for selecting the operator. Input File is SimpleCal3.txt Example Input: 1. 78.2+99.0 2. 84.3-5.2 3. 605.24 34.72 4 6.05.0 Example Output 78.2+9.0-87.2 The txt file that was given numbers are here: 78.2 99.0 84.3-5.2 605.24 34.72 112.45 601.00 5.0 A 6.0 7.8234-7.8234 7.8234 % 7.8234 0.12 0.045 567.89 = 345.23

Explanation / Answer

# include <iostream>
# include <cmath>
using namespace std;

int main()
{
char opchar;
float v1, v2;

cout << "Enter First Operand "<< "Enter Operator" << "Enter Second Operator" <<endl ;

cin >> v1 >>opchar>> v2;

switch(opchar)
{
case '+':
cout << v1+v2;
break;

case '-':
cout << v1-v2;
break;

case '*':
cout << v1*v2;
break;

case '/':
cout << v1/v2;
break;
case '<':
cout<< (v1<v2);
break;
case '>':
cout<< (v1>v2);
break;
case '=':
cout<< (v1=v2);
break;
case '^':
cout<< pow(v1,v2);
break;
default: //if other operator
cout << "Error! operator is incorrect";
break;
}

return 0;

}

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