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)
{
return total;
}
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" ...
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.
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....