Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit402c4e8

Browse files
authored
Update HexToOct.java
1 parent61aaa59 commit402c4e8

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
publicclassHexToOct
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
publicstaticinthex2decimal(Strings)
1011
{
11-
Stringstr ="0123456789ABCDEF";
12+
Stringstr ="0123456789ABCDEF";
1213
s =s.toUpperCase();
1314
intval =0;
1415
for (inti =0;i <s.length();i++)
@@ -19,20 +20,20 @@ public static int hex2decimal(String s)
1920
}
2021
returnval;
2122
}
22-
// Mainfunction that gets the hex input from user and converts it into octal.
23+
// Mainmethod that gets the hex input from user and converts it into octal.
2324
publicstaticvoidmain(Stringargs[])
2425
{
2526
Stringhexadecnum;
2627
intdecnum,i=1,j;
27-
intoctnum[] =newint[100];
28+
intoctnum[] =newint[100];//Array to store the octal from of the hex number.
2829
Scannerscan =newScanner(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)

[8]ページ先頭

©2009-2025 Movatter.jp