Create one class called Rupees, which has one member data to store amount in rupee and create another class called Paise which has member data to store amount in paise. Write a program to convert one amount to another amount with use of type conversion.
CODING:
#include<iostream.h>
#include<conio.h>
class paisa;
class rupee
{
int r;
public:
rupee(){}
void set(){cout<<"ENTER THE RUPEES :";cin>>r;}
void disp(){cout<<"CONVERT TO RUPEES:"<<r;}
int get_r(){return r;}
rupee(paisa p1);
};
class paisa
{
int p;
public:
paisa(){}
paisa(rupee r1)
{
p=r1.get_r()*100;
}
void set(){cout<<"\nENTER THE PAISA:";cin>>p;}
void disp(){cout<<"CONVERT TO PAISA:"<<p;}
int get_p(){return p;}
};
rupee::rupee(paisa p1)
{
r=p1.get_p()/100;
}
void main()
{
rupee r1;
paisa p1;
clrscr();
r1.set();
p1=r1;
p1.disp();
p1.set();
r1=p1;
r1.disp();
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class paisa;
class rupee
{
int r;
public:
rupee(){}
void set(){cout<<"ENTER THE RUPEES :";cin>>r;}
void disp(){cout<<"CONVERT TO RUPEES:"<<r;}
int get_r(){return r;}
rupee(paisa p1);
};
class paisa
{
int p;
public:
paisa(){}
paisa(rupee r1)
{
p=r1.get_r()*100;
}
void set(){cout<<"\nENTER THE PAISA:";cin>>p;}
void disp(){cout<<"CONVERT TO PAISA:"<<p;}
int get_p(){return p;}
};
rupee::rupee(paisa p1)
{
r=p1.get_p()/100;
}
void main()
{
rupee r1;
paisa p1;
clrscr();
r1.set();
p1=r1;
p1.disp();
p1.set();
r1=p1;
r1.disp();
getch();
}
Comments
Post a Comment