//C++ program to convert Indian Currency into Nepalese Currency
//two classes Indian_Currency and Nepalese_Currency have data members Rs and Paisa.
//Here, conversion routine is in destination object
#include <iostream>
using namespace std;
class Indian_Currency
{
int Rs,Paisa;
public:
Indian_Currency()
{
Rs=0;
Paisa=0;
}
Indian_Currency(int r,int p)
{
Rs=r;
Paisa=p;
}
void show()
{
cout<<Rs<<" Rs "<<Paisa<<" Paisa "<<"(Indian)"<<endl;
}
int getRs()
{
return Rs;
}
int getPaisa()
{
return Paisa;
}
};
class Nepalese_Currency
{
int Rs;
float Paisa;
public:
Nepalese_Currency()
{
Rs=0;
Paisa=0;
}
Nepalese_Currency(int r,float p)
{
Rs=r;
Paisa=p;
}
void show()
{
cout<<Rs<<" Rs "<<Paisa<<" Paisa "<<"(Nepali)"<<endl;
}
Nepalese_Currency(Indian_Currency i) //conversion routine is in destination object
{
int IRs=i.getRs();
int IPaisa=i.getPaisa();
float total_NRs;
total_NRs=(IRs+IPaisa/100)*1.6;
Rs=(int)total_NRs;
Paisa=(total_NRs-Rs)*100;
}
};
int main()
{
Indian_Currency i(12,50);
i.show();
Nepalese_Currency n;
n=i;
n.show();
return 0;
}
//two classes Indian_Currency and Nepalese_Currency have data members Rs and Paisa.
//Here, conversion routine is in destination object
#include <iostream>
using namespace std;
class Indian_Currency
{
int Rs,Paisa;
public:
Indian_Currency()
{
Rs=0;
Paisa=0;
}
Indian_Currency(int r,int p)
{
Rs=r;
Paisa=p;
}
void show()
{
cout<<Rs<<" Rs "<<Paisa<<" Paisa "<<"(Indian)"<<endl;
}
int getRs()
{
return Rs;
}
int getPaisa()
{
return Paisa;
}
};
class Nepalese_Currency
{
int Rs;
float Paisa;
public:
Nepalese_Currency()
{
Rs=0;
Paisa=0;
}
Nepalese_Currency(int r,float p)
{
Rs=r;
Paisa=p;
}
void show()
{
cout<<Rs<<" Rs "<<Paisa<<" Paisa "<<"(Nepali)"<<endl;
}
Nepalese_Currency(Indian_Currency i) //conversion routine is in destination object
{
int IRs=i.getRs();
int IPaisa=i.getPaisa();
float total_NRs;
total_NRs=(IRs+IPaisa/100)*1.6;
Rs=(int)total_NRs;
Paisa=(total_NRs-Rs)*100;
}
};
int main()
{
Indian_Currency i(12,50);
i.show();
Nepalese_Currency n;
n=i;
n.show();
return 0;
}
No comments:
Post a Comment