Thursday, February 21, 2013

OOCP (CPP) : Example # 07 : Convert Rupees into Paisa using C++

OOCP (CPP)  :  Example # 07 : Convert Rupees into Paisa  using C++

* Lets start learning CPP (C++) Using Example.

* Convert Rupees into Paisa using c++

//Written by Latest Technology Guide    
//Title : OOCP (CPP)  :  Example # 
07 : Convert Rupees into Paisa  using C++


#include <iostream.h>
#include <iomanip.h>
#include <conio.h>

class Money
{
private:
int rupees,paisa;
public:
void getdata(int,int);
void sum(Money,Money);
inline void putdata();
};
//=================================================
// GetData member function
//=================================================
void Money :: getdata(int r, int p)
{
rupees = r;
paisa = p;
}
//=================================================
//  Sum member function
//=================================================
void Money :: sum(Money m1, Money m2)
{
paisa = m1.paisa + m2.paisa;
rupees = paisa / 100;
paisa = paisa % 100;
rupees = rupees + m1.rupees + m2.rupees;
}
//=================================================
//  Putdata member function
//=================================================
void inline Money :: putdata()
{
cout << "Rupees : " << rupees << setw(10) << "Paisa  : " << paisa << endl;
}
//=================================================
// Main Function
//=================================================
void main()
{
clrscr();
Money m1,m2,m3;
m1.getdata(5,84);
m2.getdata(8,38);
m3.sum(m1,m2);

cout << "m1 amount is  ";
m1.putdata();

cout << "m2 amount is  ";
m2.putdata();

cout << "m3 amount is  ";
m3.putdata();

getch();
}

Output:

* you will find output as : conversion from rupees into paisa.

--------------------------------------------------------------------------------
OOCP (CPP)  :  Example # 07 : Convert Rupees into Paisa  using C++.

* Example shows how to convert rupees into paisa


Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment