Object as parameter

Anuj's avatarJava Programs -ISC & ICSE

Money is an unit that has 2 parts, Rupees and Paise, where 100 Paise=1 Rupee.
Design a  class named Money whose details are as follows:
Class Name : Money
Data member:
int rs, ps  : integer to store the value of Rupees and paise.
Member methods:
Money(…..)     : parameterized constructor to initialize member data
void fnShow()  : to show the member data as Money [Rs 819.75]
Money fnAdd(Money m1, Money m2) :
Add m1 and m2. Store the result in corresponding member data and return it.

Specify the class Money, giving the details of the above member data and methods. Also write the main() to create objects and call the other methods accordingly to enable the task of the adding 2 units on Money.

Program:

import java.util.*; class Money { int rs, ps; public Money(int rs1, int ps1) { rs=rs1; ps=ps1; } public Money() { rs=0; ps=0; } void fnShow()…

View original post 71 more words

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.