Hai guys My name Eddy, I'm HND Software Engineering at TATI, Malaysia, this is my 1st year of study, i need help ! somene can change below source code to templete by using C++ source code please help ... this is the source code:
-----------------------------------------------------------------------------------
#include<iostream>
using namespace std;
class calculator
{
private:
int x,y;
public:
calculator(int=1,int=1);//contructor
~calculator();//destructor
int mc();
int ac();
int sc();
int dc();
void calc(char);
}; //end of class declaration
//contructor defination
calculator::calculator(int a,int b) //destructor
{x=a;y=b;}
calculator::~calculator() //destructor
{}
int calculator::mc()
{
cout<<"\n\n"<<x<<"time"<<y<<"equals";
return(x*y);
}
int calculator::ac()
{
cout<<"\n\n"<<x<<"time"<<y<<"equals";
return(x+y);
}
int calculator::sc()
{
cout<<"\n\n"<<x<<"time"<<y<<"equals";
return(x-y);
}
int calculator::dc()
{
cout<<"\n\n"<<x<<"time"<<y<<"equals";
return(x/y);
}
void calculator::calc(char choice)
{
//int on,tw;
if (choice == '+') //This whole block checks what the user wants to calculate, and refers to the proper routine to calculate it.
{
cout<<"You selected "<<choice<<". Please enter two numbers,";
cout<<"that you want to add."<<endl;//print instructions for the user
cin>>x;//Get the value of variable on
cin>>y;//Get the value of variable tw
cout<<ac()<<"\n\n\n\aThanks for using my calculator!";//Print a thank you message
}
else if (choice =='-')
{
cout<<"You selected "<<choice<<". Please enter two numbers,\nsepperated by spaces, that you want to subtract."<<endl;
cin>>x;
cin>>y;
cout<<sc()<<"\n\n\n\aThanks for using my calculator!";
}
else if (choice =='*')
{
cout<<"You selected "<<choice<<". Please enter two numbers,\nsepperated by spaces, that you want to multiply."<<endl;
cin>>x;
cin>>y;
cout<<mc()<<"\n\n\n\aThanks for using my calculator!";
}
else if (choice =='/')
{
cout<<"You selected "<<choice<<". Please enter two numbers,\nsepperated by spaces, that you want to divide."<<endl;
cin>>x;
cin>>y;
cout<<dc()<<"\n\n\n\aThanks for using my calculator";
}
else
{
cout<<"\nPlease reenter that value.\n\a";
cin>>choice;
calc(choice);
}
}
int main()
{
calculator object(5,6);
char choice;
while (choice != 'e')
{
cout<<"\nPlease enter +,-,*, or / and then two numbers,\nsepperated by spaces, that you wish to\nadd,subtract,multiply,or divide.\nType e and press enter to exit.";
cin>>choice;
if (choice != 'e')
{
object.calc(choice);
}
}
return 0;
}
Please someone help me convert to templete...please... as soon as posible..