Java Program to Convert Octal to Decimal

« Previous Program Next Program »

Convert Octal to Decimal

To convert octal to decimal in Java Programming, you have to ask to the user to enter any number in octal number format to convert it into equivalent decimal number format to display the equivalent value in decimal number system as shown in the following program.

Java Programming Code to Convert Octal to Decimal

Following Java program ask to the user to enter any octal number to convert it into decimal, then display the result on the screen :

/* Java Program Example - Convert Octal to Decimal */
import java.util.Scanner;

public class JavaProgram
    public static void main(String args[])
        int octnum, decnum=0, i=0, orig;
        Scanner scan = new Scanner(;
        System.out.print("Enter Octal Number : ");
        octnum = scan.nextInt();
        orig = octnum;
        while(octnum != 0)
            decnum = decnum + (octnum%10) * (int) Math.pow(8, i);
            octnum = octnum/10;
        System.out.print("Equivalent Decimal Value of " + orig + " is :\n");

When the above Java Program is compile and executed, it will produce the following output:

Java Program convert octal to decimal

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

Java Online Test

« Previous Program Next Program »

© Copyright 2021. All Rights Reserved.