-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNearestExit.java
More file actions
86 lines (51 loc) · 1.42 KB
/
NearestExit.java
File metadata and controls
86 lines (51 loc) · 1.42 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Nearest Exit
There are two exits in a bus with 100 seats:
First exit is located beside seat number 1.
Second exit is located beside seat number 100.
Seats are arranged in a straight line from 1 to 100 with equal spacing between any 2 adjacent seats.
A passenger prefers to choose the nearest exit while leaving the bus.
Determine the exit taken by passenger sitting on seat X.
Input Format
The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists a single integer X, denoting the seat number.
Output Format
For each test case, output LEFT if the passenger chooses the exit beside seat 1, RIGHT otherwise.
You may print each character of the string in uppercase or lowercase (for example, the strings LEFT, lEft, left, and lEFT will all be treated as identical).
Constraints
1 ≤ T ≤ 100
1 ≤ X ≤ 100
Sample 1:
Input
6
1
50
100
30
51
73
Output
LEFT
LEFT
RIGHT
LEFT
RIGHT
RIGHT
*/
import java.util.Scanner;
public class NearestExit {
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=0;i<n;i++){
int x=sc.nextInt();
if(x>50){
System.out.println("RIGHT");
}else{
System.out.println("LEFT");
}
}
}
}