-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecimalConverter.java
More file actions
31 lines (31 loc) · 940 Bytes
/
decimalConverter.java
File metadata and controls
31 lines (31 loc) · 940 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
class decimalConverter
{
public static void main(String args[])
{
int n,b,i,j,k=1;
n=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
j=n;
while(j>=b)
{
k=k*b;
j=j/b;
}
while(k>0)
{
i=n/k;
switch(i)
{
case 10:System.out.print("A ");break;
case 11:System.out.print("B ");break;
case 12:System.out.print("C ");break;
case 13:System.out.print("D ");break;
case 14:System.out.print("E ");break;
case 15:System.out.print("F ");break;
default:System.out.print(i+" ");
}
n=n%k;
k=k/b;
}
}
}