-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathLandHo.java
29 lines (20 loc) · 809 Bytes
/
LandHo.java
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
import java.util.Scanner;
public class LandHo {
static int getWaitingTime(int numPeopleAhead) {
int tripDuration = 10;
int boatCapacity = 20;
// add 1 to account for yourself
int numBoatsNeeded = (int) Math.ceil((double) (numPeopleAhead + 1) / boatCapacity);
// tripDuration * 2 because of round trip
// numBoatsNeeded - 1 to not include our boat
int waitingTime = (numBoatsNeeded - 1) * tripDuration * 2;
int totalWaitingTime = waitingTime + tripDuration;
return totalWaitingTime;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numPeopleAhead = scanner.nextInt();
System.out.println(getWaitingTime(numPeopleAhead));
scanner.close();
}
}