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:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: May 31, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles