The union bank needs to convert rupees to dollar and vice versa perform this conversion using conversion routines (here rupees and dollar are two classes).
#include <iostream>
using namespace std;
class Rupee;
class Dollar{
public:
float x;
Dollar(){}
Dollar(float y):x(y){}
void operator=(Rupee R);
};
class Rupee{
public:
float y;
Rupee(){}
Rupee(float x):y(x){}
void operator=(Dollar D){
y = D.x * 74.4;
}
};
void Dollar::operator=(Rupee R){
x = R.y * 0.013;
}
int main(){
cout<<"Enter dollars to convert to Rupees: ";
float x;
cin>>x;
Dollar D(x);
Rupee R;
R = D;
cout<<R.y<<" Rupees.\n";
cout<<"Enter rupees to convert to dollars: ";
cin>>x;
R = Rupee(x);
D = R;
cout<<D.x<<" Dollars.\n";
return 0;
}
Comments
Leave a comment