-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadixFind.java
37 lines (32 loc) · 917 Bytes
/
RadixFind.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
import java.util.*;
public class RadixFind
{
public static void main(String args[])
{
try (Scanner sc = new Scanner(System.in)) {
String num;
System.out.println("Enter a Number");
num=sc.nextLine();
if(num.matches("[01]+"))
{
System.out.println("Binary radix= 2");
}
else if(num.matches("[0-7]+"))
{
System.out.println("Octal Radix=8");
}
else if(num.matches("[0-9]+"))
{
System.out.println("Decimal Radix =10");
}
else if(num.matches("[0-9A-F]+"))
{
System.out.println("Hexa radix= 16");
}
else
{
System.out.println("INVALID");
}
}
}
}