Answer to Question #186171 in C++ for Ajith

Question #186171

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).


1
Expert's answer
2021-04-28T06:16:18-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS