Write a C++program that do the following: a. Define a class called Calculator. b
ID: 3614379 • Letter: W
Question
Write a C++program that do the following:a. Define a class called Calculator.
b. Declare the object Cal of type Calculator.
c. Define a member function Display_sum that receive two intNumber1 and Number2 then print the sum of these twonumbers.
d. Define a member function Display_multiply that receive two intNumber1 and Number2 then print the multiplication of these twonumbers.
e. Test your functions. Write a C++program that do the following:
a. Define a class called Calculator.
b. Declare the object Cal of type Calculator.
c. Define a member function Display_sum that receive two intNumber1 and Number2 then print the sum of these twonumbers.
d. Define a member function Display_multiply that receive two intNumber1 and Number2 then print the multiplication of these twonumbers.
e. Test your functions.
Explanation / Answer
classcalculator{
public : int a,b;
calculator(){}
void Display_sum()
{
cout<<"please enter the first no";
cin>>a;
cout<<" please enter the second no";
cin>>b;
cout<<"the answer is "<< a+b<<' ';}
void Display_multiply()
{
cout<<"please enter the first no";
cin>>a;
cout<<" please enter the second no";
cin>>b;
cout<<"the answer is "<< a*b<<' ';}
};
main(){
calculator cal; //object of the class
cal.Display_sum();// test of firstfunction
cal.Display_multiply();// test ofsecond function
system("pause");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.