Define a class called ParkingLot with the following description :
Instance variables/data members :
int vno : To store the vehicle number
int hours : To store the number of hours the vehicle is parked in the parking lot
double bill : To store the bill amount
Member methods :
parameterised constructor : To input and store the vehicle no and hours parked.
default constructor : to assign vehicle no as 0 hours parked as 0
void calculate() :To compute the parking charge at the rate of Rs3 for the first hour or part thereof, and Rs 1.50 for each additional hour or part thereof.
void display() : To display the detail
Write a main method to create an object of the class and call the above methods
public class PARTINGLOT
{
int vno;
int hours;
double bill;
public PARTINGLOT(int vn, int hrs)
{
vno=vn;
hours=hrs;
}
public PARTINGLOT()
{
vno=0;
hours=0;
}
public void calculate()
{
if ( hours <=1)
bill = 3;
else
bill= 3+(hours-1)*1.5f;
}
public void display()
{
System.out.println(" Veh no: "+vno);
System.out.println(" hours : "+hours);
System.out.println(" Bill Amt: "+bill);
}
public static void main()
{
PARTINGLOT t1 = new PARTINGLOT(9224, 4);
t1.calculate();
t1.display();
}
}