-
Notifications
You must be signed in to change notification settings - Fork 3
/
FS(A2-Batch)D1P3.java
59 lines (46 loc) · 1.03 KB
/
FS(A2-Batch)D1P3.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
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
/*Mr.Donald is teaching his students about number systems.
-He has given assignment to the students to check whether the
given number N belongs to binary number system or not.
Your task is to help the students in completing their assignment.
Input Format:
-------------
An Integer N.
Output Format:
--------------
Print true or false.
Sample Input:1
---------------
111100
Sample Output:1
---------------
true
Sample Input:2
---------------
1120
Sample Output:1
---------------
false
*/
import java.util.*;
public class FS(A2-Batch)D1P3
{
static boolean check(String s)
{
boolean flag = true;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)!='1' && s.charAt(i)!= '0')
{
flag = false;
break;
}
}
return flag;
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String n = sc.nextLine();
System.out.println(check(n));
}
}