-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogicalOperators.java
More file actions
41 lines (32 loc) · 1019 Bytes
/
LogicalOperators.java
File metadata and controls
41 lines (32 loc) · 1019 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
39
40
41
import java.util.Scanner;
public class LogicalOperators{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter number:");
int x = scanner.nextInt();
scanner.nextLine();
scanner.close();
if(x > 0 && x < 10){
System.out.println("X is between 0 and 10");
}
else{
System.out.println("X is not between 0 and 10");
}
System.out.println("Do you want to quit ? press 'q' or 'Q'");
String response = scanner.next(); //next(); only read one word
if(response.equals("Q") || response.equals("q")){
System.out.println("Quit the game");
}
else{
System.out.println("Still playing");
}
System.out.println("Do you want to quit ? press 'q' or 'Q'");
String answer = scanner.next(); //next(); only read one word
if(!answer.equals("Q") && !answer.equals("q")){
System.out.println("Still playing");
}
else{
System.out.println("Quit the game");
}
}
}