Hi, Your class will have an additional method that computes and returns the actual cost per month. This is defined as the total cost divided by the number of months.
I do not know how to initialize the two variables. help me please
this is my code:
public class LeaseEval
{
private String custName; // customer's name
private double monthPay; // monthly payment
private int termLease; // the term of the lease in months
private double downPay; // down payment
private int maxFreeMiles; // maximun amount of free miles
private int overMaxMiles; // The charge per mile for all miles over the max
private double milesDriven; // The number of miles actually driven
// I create a constructor
public LeaseEva(String theCustName, double theMonthPay, int theTermLease,
double theDownPay, int theMaxFreeMiles, int theOverMaxMiles, double theMilesDriven)
{
custName = theCustName;
monthPay = theMonthPay;
termLease = theTermLease;
downPay = theDownPay;
maxFreeMiles = theMaxFreeMiles;
overMaxMiles = theOverMaxMiles;
milesDriven = theMilesDriven;
}
// Here are the "gets" for the variables
public String getTheCustName()
{
return custName;
}
public double getTheMonthPay()
{
return monthPay;
}
public int getTheTermLease()
{
return termLease;
}
public double getTheDownPay()
{
return downPay;
}
public int getTheMaxFreeMiles()
{
return maxFreeMiles;
}
public int getTheOverMaxMiles()
{
return overMaxMiles;
}
public double getTheMilesDriven()
{
return milesDriven;
}
// the mathematical part of the program is here
public double costperMonth()
{
double totalCost;
double numMonths;
double costMonth;
// THESE TWO VARIABLES
totalCost =
numMonths =
costMonth = totalCost/numMonths;
return costMonth;
}
}
Thanks.
Daniel