-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrobogramatic.java
More file actions
29 lines (27 loc) · 1 KB
/
strobogramatic.java
File metadata and controls
29 lines (27 loc) · 1 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
import java.util.Scanner;
public class strobogramatic {
public static boolean stroboCheck(String num) {
for (int i = 0; i < (num.length() / 2) + 1; i++) {
int thing = num.length() - i - 1;
if (num.charAt(i) == '0' && num.charAt(thing) != '0') {
return false;
} else if (num.charAt(i) == '1' && num.charAt(thing) != '1') {
return false;
} else if (num.charAt(i) == '6' && num.charAt(thing) != '9') {
return false;
} else if (num.charAt(i) == '8' && num.charAt(thing) != '8') {
return false;
} else if (num.charAt(i) == '9' && num.charAt(thing) != '6') {
return false;
}
}
return true;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the number ");
String num = in.next();
System.out.println(stroboCheck(num));
in.close();
}
}