-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathd.java
More file actions
51 lines (50 loc) · 1.05 KB
/
Copy pathd.java
File metadata and controls
51 lines (50 loc) · 1.05 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
package switchprograms;
import java.util.*;
public class dec
{
public static void main()
{
Scanner ob=new Scanner(System.in);
System.out.println("enter number");
int n=ob.nextInt();
int a,i=0;String b[]={"A","B","C","D","E","F"};
int x=n;String s1="",s2="";
while(n!=0)
{
a=n%16;
String a1=String.valueOf(a);
if(a==10)
{
s1=b[0];
}
else if(a==11)
{
s1=b[1];
}
else if(a==12)
{
s1=b[2];
}
else if(a==13)
{
s1=b[3];
}
else if(a==14)
{
s1=b[4];
}
else if(a==15)
{
s1=b[5];
}
else
{
s1=a1;}
int t=(int)Math.pow(10,i);int q=a*t;
i++;
s2=s1+q+s2;
n=n/16;
}
System.out.println(s2);
}
}