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

First of all please don\'t copy from Internet and paste. I can do that. Also, I

ID: 3546415 • Letter: F

Question

First of all please don't copy from Internet and paste. I can do that. Also, I need program work.

Thank you


In this assignment, you are asked to develop a C++ calculator using the switch statements and functions. Your calculator should perform addition, subtraction, multiplication, division and modular operations. The program will read the numbers and mathematical operator from user input. Then, the program will call the relevant mathematical function to perform the calculation.

After one mathematical operation, ask the user "Do you want to do another calculation?". If the user answers 'y' or 'Y', then allow the user to perform another mathematical calculation. Otherwise, terminate the program.

Your program should satisfy the following minimum requirements:

?  Switch statements to make selection between mathematical operations.

?  A void function to read the user inputs.

?  A value returning function to perform the addition.

?  A value returning function to perform the subtraction.

?  A value returning function to perform the multiplication.

?  A value returning function to perform the division.

?  A value returning function to perform the modular operation.

Explanation / Answer

#include< iostream>
#include<math.h>
using namespace std;


float DISPLAYADD(float a ,float b);
float DISPLAYDIFFERENCE(float a ,float b);
float DISPLAYPRODUCT(float a ,float b);
float DISPLAYQUOTIENT(float a ,float b);
float DISPLAYMODULUS(float a ,float b);


int main(){

float NUM1,NUM2;

  
    int choice =0;
    char choice2[2]="y";
    do{
      cout<<" ++++++++++++++++++++++++++++++++++ ";
      cout<<"Enter first number : ";
      cin>>NUM1;
      cout<<" Enter second number : ";
      cin>>NUM2;
      cout<<" Two numbers you have entered are "<<NUM1 <<" and "<<NUM2;

      cout<<endl;
      cout<<" 1.ADD"<<endl;
      cout<<" 2.SUBSTRACTION"<<endl;
      cout<<" 3.MULTIPLICATION"<<endl;
      cout<<" 4.DIVISION"<<endl;
      cout<<" 5.MODULAR"<<endl;

      cout<<" Please choose from the menu: ";
      cin>>choice;
    switch(choice){
                       
   case 1:
           cout<<"The sum is : "<<showpoint << fixed << setprecision(3)<<DISPLAYADD(NUM1,NUM2)<<endl;
                break;
        case 2:
        cout<<"The difference is : "<<showpoint << fixed << setprecision(3)<<DISPLAYDIFFERENCE(NUM1,NUM2)<<endl;
                 break;
   case 3:
           cout<<"The product is : "<<showpoint << fixed << setprecision(3)<<DISPLAYPRODUCT(NUM1,NUM2)<<endl;
             break;
        case 4:

       if(NUM2!=0){
       cout<<"The quotient is : "<<showpoint << fixed << setprecision(3)<<DISPLAYQUOTIENT(NUM1,NUM2)<<endl;
                }
                else
                cout<<"disisor can not be zero "<<endl;
                break;
        case 5:
                if(NUM2!=0){
            cout<<"The remainder is : "<<showpoint << fixed << setprecision(3)<<DISPLAYMODULUS(NUM1,NUM2)<<endl;
                }
                else
                cout<<"disisor can not be zero "<<endl;
                break;
        case default:
               cout<<"Wrong Choice"<<endl;
        }

  
       cout<<"Do you want to do another calculation? : ";
       cin<<choice2;
     }while(choice2=="y"||choice2=="Y");
return 0;

}

float DISPLAYADD(float a ,float b){
return (a+b);
}
float DISPLAYDIFFERENCE(float a ,float b){
return (a-b);
}
float DISPLAYPRODUCT(float a ,float b){
return (a*b);
}
float DISPLAYQUOTIENT(float a ,float b){
return (a/b);
}
float DISPLAYMODULUS(float a ,float b){
return ( fmodf(a,b) );
}