-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKSLC.java
More file actions
44 lines (37 loc) · 1.24 KB
/
KSLC.java
File metadata and controls
44 lines (37 loc) · 1.24 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
public class KSLC {
static final int MAX_WEIGHT = 1020; // Maximum weight in kg
static final int MAX_PEOPLE = 8; // Maximum number of people allowed
static int currentWeight = 0;
static int peopleInLift = 0;
static boolean liftFull = false;
public static void main(String[] args) {
while (true) {
detectPeopleInLift();
liftFull = checkWeight();
if (liftFull) {
System.out.println("Lift full!");
skipFloors();
} else {
moveLiftToFloor();
}
System.out.println("People in lift: " + peopleInLift + ", Weight: " + currentWeight + " kg");
}
}
public static void detectPeopleInLift() {
if (peopleInLift < MAX_PEOPLE) {
peopleInLift++;
}
}
public static boolean checkWeight() {
return currentWeight >= MAX_WEIGHT || peopleInLift >= MAX_PEOPLE;
}
public static void skipFloors() {
while (checkWeight()) {
System.out.println("Lift full, skipping floors...");
peopleInLift--; // Simulate people exiting
}
}
public static void moveLiftToFloor() {
System.out.println("Lift moving...");
}
}