# Method calculate 2 object using constructor with parameter

• November 20th, 2012, 08:14 PM
DavidXCode
Method calculate 2 object using constructor with parameter
Quote:

public class BillTest
{
public static void main (String[]arg)
{
Bill mum=new Bill(130,100); //object mum
Bill sister=new Bill(200,50); //object sister
Bill family=new Bill(0,0); // object family
family=family.calculateTotal(mum,sister);
System.out.println("Total bill:");
family.calculateBill();
}
}
Quote:

public class Bill
{
int airtime;
int totalSms;
int total;
public double callrate=0.25;
public double smsrate=0.05;

Bill(int a, int s)
{
airtime = a;
totalSms= s;
}

public int calculateTotal(mum, sister)
{

}

public double calculateBill()
{
return (airtime * callrate+ totalSms * smsrate);
}

}
What method i should write the calculateTotal(mum,sister)?
calculate the total " airtime from mum and sister" and "totalSms from mum and sister" ...
• November 21st, 2012, 01:31 AM
Junky
Re: Method calculate 2 object using constructor with parameter
Are you sure you have the requirements correct? Do you really need a "family" Bill? I would think that the total Bill is simply mum's Bill + sister's Bill.
• November 21st, 2012, 08:31 PM
DavidXCode
Re: Method calculate 2 object using constructor with parameter
class BillTest is given from question...
what i have to do is complete the Bill class.
what method can be use to calculatetotal of 2 object mum ans sis with 2 parameter?
the calculatetotal() is calculate the total airtime of mum&sister , and totalsms of mum&sister.
anyone can solve this? I'm going out of my mind....