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:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.