Skip to content

Commit 61aaa59

Browse files
authored
Update HexToOct.java
1 parent 37838f6 commit 61aaa59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Conversions/HexToOct.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import java.util.Scanner;
55

66
public 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
{

0 commit comments

Comments
 (0)