-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathParkingLot.java
More file actions
49 lines (47 loc) · 1.06 KB
/
ParkingLot.java
File metadata and controls
49 lines (47 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.*;
class ParkingLot
{
int vno;
int hours;
double bill;
public void input()throws IOException
{
BufferedReader y = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input the vehicle number");
vno = Integer.parseInt(y.readLine());
System.out.println("Input the number of hours");
hours = Integer.parseInt(y.readLine());
}
public void calculate()
{
if(hours<=0)
{
System.out.println("WRONG INPUT");
System.exit(0);
}
else if((hours>0)&&(hours<=1))
{
bill = hours*3.0;
System.out.println("PARKING CHARGES = "+ bill);
}
else
{
bill = 3.0+(hours-1)*3;
System.out.println("PARKING CHARGES + "+bill);
}
}
public void display()
{
System.out.println("vehicle number = "+vno);
System.out.println("total time = "+hours);
System.out.println("total charges = "+bill);
}
public static void main(String args[])throws IOException
{
ParkingLot obj = new ParkingLot();
obj.input();
obj.calculate();
obj.display();
System.out.println();
}
}