-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParkingLot.java
More file actions
38 lines (32 loc) · 904 Bytes
/
ParkingLot.java
File metadata and controls
38 lines (32 loc) · 904 Bytes
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
import java.util.Scanner;
import java.lang.String;
public class ParkingLot {
public String vno;
public int hours;
public double bill;
public void input() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter vehicle number: ");
vno = sc.nextLine();
System.out.print("Enter hours: ");
hours = sc.nextInt();
sc.close();
}
public void calculate() {
if (hours <= 1)
bill = 3;
else
bill = 3 + (hours - 1) * 1.5;
}
public void display() {
System.out.printf("\n\nVehicle number: " + vno.toUpperCase());
System.out.printf("\nHours: " + hours);
System.out.println("\nBill: " + bill);
}
public static void main(String args[]) {
ParkingLot obj = new ParkingLot();
obj.input();
obj.calculate();
obj.display();
}
}