Skip to content

Commit 402c4e8

Browse files
authored
Update HexToOct.java
1 parent 61aaa59 commit 402c4e8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Conversions/HexToOct.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
public class HexToOct
77
{
8-
//Function that takes the Hexadecimal number as input and returns the decimal form.
8+
/*Function that takes the Hexadecimal number as input and returns the decimal form.
9+
The input is recieved as a string and the return type is int*/
910
public static int hex2decimal(String s)
1011
{
11-
String str = "0123456789ABCDEF";
12+
String str = "0123456789ABCDEF";
1213
s = s.toUpperCase();
1314
int val = 0;
1415
for (int i = 0; i < s.length(); i++)
@@ -19,20 +20,20 @@ public static int hex2decimal(String s)
1920
}
2021
return val;
2122
}
22-
// Main function that gets the hex input from user and converts it into octal.
23+
// Main method that gets the hex input from user and converts it into octal.
2324
public static void main(String args[])
2425
{
2526
String hexadecnum;
2627
int decnum, i=1, j;
27-
int octnum[] = new int[100];
28+
int octnum[] = new int[100]; //Array to store the octal from of the hex number.
2829
Scanner scan = new Scanner(System.in);
2930

3031
System.out.print("Enter Hexadecimal Number : ");
31-
hexadecnum = scan.nextLine();
32+
hexadecnum = scan.nextLine();
3233

3334
// first convert hexadecimal to decimal
3435

35-
decnum = hex2decimal(hexadecnum);
36+
decnum = hex2decimal(hexadecnum); //Pass the string to the hex2decimal function and get the decimal form in variable decnum
3637

3738
// convert decimal to octal
3839

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy