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

Commit61aaa59

Browse files
authored
Update HexToOct.java
1 parent37838f6 commit61aaa59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎Conversions/HexToOct.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
importjava.util.Scanner;
55

66
publicclassHexToOct
7-
{
7+
{
8+
//Function that takes the Hexadecimal number as input and returns the decimal form.
89
publicstaticinthex2decimal(Strings)
910
{
1011
Stringstr ="0123456789ABCDEF";
@@ -17,7 +18,8 @@ public static int hex2decimal(String s)
1718
val =16*val +n;
1819
}
1920
returnval;
20-
}
21+
}
22+
// Main function that gets the hex input from user and converts it into octal.
2123
publicstaticvoidmain(Stringargs[])
2224
{
2325
Stringhexadecnum;
@@ -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)

[8]ページ先頭

©2009-2025 Movatter.jp