In this section, you will learn to convert an octal number to decimal. The following program helps you converts number octal to decimal.
Description of code:
This program takes an octal number at console converts it into decimal number using parseInt() method. This method parses the string value as a signed integer in the radix specified by the second argument as 8. And you get the decimal number.
Integer.parseInt(oct, 8): This method takes an int value in a string format and it returns an Integer object. It converts an octal number into decimal and takes two parameters. First argument passed is a specified String which is parsed using the radix given through the second argument. The first parameter interprets as representing a signed integer in the radix specified by the second parameter.
Keyboard as :S- This is a string to be parsed.
Radix (as a use integer value):- The radix represents an integer value to be parsed in the interpreting string.
Here is the code of this program:
Output of this program:
Enter the octal number:
Liked it! Share this Tutorial