File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 4
4
import java .util .Scanner ;
5
5
6
6
public class HexToOct
7
- {
7
+ {
8
+ //Function that takes the Hexadecimal number as input and returns the decimal form.
8
9
public static int hex2decimal (String s )
9
10
{
10
11
String str = "0123456789ABCDEF" ;
@@ -17,7 +18,8 @@ public static int hex2decimal(String s)
17
18
val = 16 *val + n ;
18
19
}
19
20
return val ;
20
- }
21
+ }
22
+ // Main function that gets the hex input from user and converts it into octal.
21
23
public static void main (String args [])
22
24
{
23
25
String hexadecnum ;
@@ -39,7 +41,7 @@ public static void main(String args[])
39
41
octnum [i ++] = decnum %8 ;
40
42
decnum = decnum /8 ;
41
43
}
42
-
44
+ //Print the octal form of the number.
43
45
System .out .print ("Equivalent Octal Number is :\n " );
44
46
for (j =i -1 ; j >0 ; j --)
45
47
{
You can’t perform that action at this time.
0 commit comments