Monday, January 20, 2014

C++ Program for Type Conversion from Dollar To Rupees

with 0 Comment
#include<iostream.h>
#include<conio.h>
class rupees;
class dollar
{
public:
float doll;
dollar()
{
doll=0;
}
dollar(float doll1)
{
doll=doll1;
}
int getdoll()
{
return(doll);
}
void display()
{
cout<<"\n\n Dollar:"<<"$"<<doll;
}
};
class rupee
{
public:
float rup;
rupee(float rup1)
{
rup=rup1;
}
rupee(dollar d)
{
rup=d.getdoll()*(51.1265);
}
operator dollar()
{
dollar d;
d.doll=rup*(0.0196);
return d;
}
void display()
{
cout<<"\n\n Rupees:"<<"Rs"<<rup;
}
};
void main()
{
float d1,r1;
clrscr();
cout<<"\n\t\t TYPE CONVERSION";
cout<<"\n\t\t ************";
cout<<"\n\n Enter the rupees:";
cin>>r1;
rupee rs(r1);
dollar dr;
dr=rs;
cout<<"\n\n After Conversion";
dr.display();
cout<<"\n\n Enter the Dollar:";
cin>>d1;
dollar dr1(d1);
rs=dr1;
cout<<"\n\n After Conversion";
rs.display();
getch();
}


-------------
OUTPUT:
-------------
 TYPE CONVERSION
*******************
Enter the rupees:50
After Conversion
    Dollar :$0.98

Enter the dollar:4
After Conversion
    Rupees:Rs 204.505997

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive