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

This is what I have so far: #include<iostream> using namespace std; double added

ID: 3775400 • Letter: T

Question

This is what I have so far:

#include<iostream>
using namespace std;
double added(double Num1, double Num2, double& Sum)
double multiplied(double Num1, double Num2, double& product )
double divided(double Num1, double Num2, double& quotient)
double subtracted(double Num1, double Num2, double& difference)
int main()
{
   double Num1, Num2, answer;
   int code;
cout<<"Please enter one number: ";
   cin>>Num1;
   cout<<"Please enter a second number: ";
   cin>>Num2;
   while(Num1!=0 || Num2!=0)
   {
  
  
  
   cout<<endl;
  
   cout<<"1.   + ";
   cout<<"2.   * ";
   cout<<"3.   / ";
   cout<<"4.   - "<<endl;
  
   cout<<"Please indicate a code: ";
   cin>>code;
   cout<<endl;  
  
  
  
       switch(code)
   {
       case 1:
           answer=Num1+Num2;
           cout<<"The first number is "<<Num1
           <<" and the second number is "<< Num2<<"."
           <<" Your sum is "<<answer<< "."<<endl;
           break;
      
       case 2:
           answer=Num1*Num2;
           cout<<"The first number is "<<Num1
           <<" and the second number is "<< Num2<< "."<<
           cout<<"Your product i: "<<answer<< "."<<endl;
           break;
       case 3:
           answer=Num1/Num2;
           cout<<"The first number is "<<Num1
           <<" and the second number is "<< Num2<< "."
           <<cout<<"Your quotient is "<<answer<< "."<<endl;
           break;
       case 4:
           answer=Num2-Num1;
           cout<<"The first number is "<<Num1
           <<" and the second number is "<< Num2<< "."
           <<cout<<"Your difference is "<<answer<< "."<<endl;
           break;
       default: cout<<"You entered 0 for both numbers.";
   }
  
  
}

return 0;
}

CSC 170L Computer Programming Lab Week 12 This lab is due to Blackboard by 12:20 pm. At this time upload whatever you have completed. The lab will not be extended past 12:30 pm Goal: Use selection and repetition to write a program which uses functions program should Problem Statement A program is required which will act as a calculator. The the following prompt the user to enter 2 integers and a code. The program should perform actions based on the code entered A code of 1 indicates that the two numbers should be added number A code of 2 indicates that the two numbers should be multiplied second A code of 3 indicates that the first number should be divided by the the second A code of 4 indicates that the first number should be subtracted from number as well as the sum This The program should then print both numbers, with appropriate labels pri then be difference, product or quotient with an appropriate label indicating what is being process should be repeated until 2 zeros are entered. An appropriate message should printed to notify the user of the end of the program Sample output Please enter a number 3 Please enter another number 6 is 9 Please enter the code 1 6. The sum of these numbers The first number is 3 and second number is Please enter a number 4 Please enter another number 5 20 Please enter the code 2 The product of these numbers is The first number is 4 and the second number is 5. Please enter a number 0 Please enter another number 0 Good Bye

Explanation / Answer

#include<iostream>
using namespace std;
int main()
{
double Num1, Num2, answer;
int code;
cout<<"Please enter one number: ";
cin>>Num1;
cout<<"Please enter a second number: ";
cin>>Num2;
while(Num1!=0 || Num2!=0)
{
cout<<endl;
  
cout<<"1. + ";
cout<<"2. * ";
cout<<"3. / ";
cout<<"4. - "<<endl;
  
cout<<"Please indicate a code: ";
cin>>code;
cout<<endl;
  
  
  
switch(code)
{
case 1:
answer=Num1+Num2;
cout<<"The first number is "<<Num1
<<" and the second number is "<< Num2<<"."
<<" Your sum is "<<answer<< "."<<endl;
break;
  
case 2:
answer=Num1*Num2;
cout<<"The first number is "<<Num1
<<" and the second number is "<< Num2<< "."<<
cout<<"Your product i: "<<answer<< "."<<endl;
break;
case 3:
answer=Num1/Num2;
cout<<"The first number is "<<Num1
<<" and the second number is "<< Num2<< "."
<<cout<<"Your quotient is "<<answer<< "."<<endl;
break;
case 4:
answer=Num2-Num1;
cout<<"The first number is "<<Num1
<<" and the second number is "<< Num2<< "."
<<cout<<"Your difference is "<<answer<< "."<<endl;
break;
default: cout<<"Invalid Code"<<endl;
}
cout<<"Please enter one number: ";
cin>>Num1;
cout<<"Please enter a second number: ";
cin>>Num2;
  
}
cout << "Good Bye!";
return 0;
}

/* sample output
The first number is 1 and the second number is 2. Your sum is 3.
Please enter one number: 0
Please enter a second number: 1

1. +
2. *
3. /
4. -

Please indicate a code: 1

The first number is 0 and the second number is 1. Your sum is 1.
Please enter one number: 0
Please enter a second number: 0
Good Bye!
*/

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