diff --git a/Conversions/HexToOct.java b/Conversions/HexToOct.java index 275fe84e..47b8d7c7 100644 --- a/Conversions/HexToOct.java +++ b/Conversions/HexToOct.java @@ -5,10 +5,11 @@ import java.util.Scanner; public class HexToOct { - //Function that takes the Hexadecimal number as input and returns the decimal form. + /*Function that takes the Hexadecimal number as input and returns the decimal form. + The input is recieved as a string and the return type is int*/ public static int hex2decimal(String s) { - String str = "0123456789ABCDEF"; + String str = "0123456789ABCDEF"; s = s.toUpperCase(); int val = 0; for (int i = 0; i < s.length(); i++) @@ -19,20 +20,20 @@ public class HexToOct } return val; } - // Main function that gets the hex input from user and converts it into octal. + // Main method that gets the hex input from user and converts it into octal. public static void main(String args[]) { String hexadecnum; int decnum, i=1, j; - int octnum[] = new int[100]; + int octnum[] = new int[100]; //Array to store the octal from of the hex number. Scanner scan = new Scanner(System.in); System.out.print("Enter Hexadecimal Number : "); - hexadecnum = scan.nextLine(); + hexadecnum = scan.nextLine(); // first convert hexadecimal to decimal - decnum = hex2decimal(hexadecnum); + decnum = hex2decimal(hexadecnum); //Pass the string to the hex2decimal function and get the decimal form in variable decnum // convert decimal to octal