Answer to Question #266795 in C++ for Nor

Question #266795

Make a simple calculator using switch statement. Use 4 mathematical operations in

mathematics.

a. When you type A in the console, it will add two numbers

1

st number: 198

2

nd number: 196

b. When you type S, it will subtract two numbers.

1

st number: 145

2

nd number: 67

c. When you type D, it will divide two numbers.

1

st number: 256

2

nd number: 8

d. When you type M, it will multiply two numbers.

1

st number: 125

2

nd number: 5


1
Expert's answer
2021-11-16T18:37:52-0500
#include <iostream>


using namespace std;


int main()
{
    char size;
    int Number_1,Number_2,result;
    cout << "THis is a simple calculator" << endl;
    cout<<"Make the choice"<<endl;
    cin>>size;
    switch (size){
case 'A':
    Number_1=198,Number_2=196;
   result=Number_1+Number_2;
    cout<<"Result is: " <<result;
    break;
case 'S':
     Number_1=145,Number_2=67;
    result=Number_1-Number_2;
    cout<<"Result is: " <<result;
    break;
case 'D':
   Number_1=256,Number_2=8;
     result=Number_1/Number_2;
    cout<<"Result is: " <<result;
    break;
case 'M':
   Number_1=125,Number_2=5;
    result=Number_1*Number_2;
    cout<<"Result is: " <<result;
    break;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS