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 44import java .util .Scanner ;
55
66public class HexToOct
7- {
7+ {
8+ //Function that takes the Hexadecimal number as input and returns the decimal form.
89 public static int hex2decimal (String s )
910 {
1011 String str = "0123456789ABCDEF" ;
@@ -17,7 +18,8 @@ public static int hex2decimal(String s)
1718 val = 16 *val + n ;
1819 }
1920 return val ;
20- }
21+ }
22+ // Main function that gets the hex input from user and converts it into octal.
2123 public static void main (String args [])
2224 {
2325 String hexadecnum ;
@@ -39,7 +41,7 @@ public static void main(String args[])
3941 octnum [i ++] = decnum %8 ;
4042 decnum = decnum /8 ;
4143 }
42-
44+ //Print the octal form of the number.
4345 System .out .print ("Equivalent Octal Number is :\n " );
4446 for (j =i -1 ; j >0 ; j --)
4547 {
You can’t perform that action at this time.
0 commit comments