Menu Close

Decimal to Octal in Java …FTC

Java program to convert from decimal to octal.

Input:
Decimal Number:  50

Output:
Octal Number:  62
import java.io.*;
import java.util.*;
public class temp{
  public static void main(String[] args) {
    int deci;
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter the Decimal Number:  ");
    deci = scan.nextInt();
    System.out.println("Octal Number is:  "+Integer.toOctalString(deci));
	}
}

INPUT_1:
Enter the Decimal Number:
123

OUTPUT:
Octal Number is:  173


INPUT_2:
Enter the Decimal Number:
25

OUTPUT:
Octal Number is:  31


INPUT_3:
Enter the Decimal Number:
50

OUTPUT:
Octal Number is:  62


INPUT_4:
Enter the Decimal Number:
54

OUTPUT:
Octal Number is:  66


INPUT_5:
Enter the Decimal Number:
100

OUTPUT:
Octal Number is:  144


INPUT_6:
Enter the Decimal Number:
1000

OUTPUT:
Octal Number is:  1750


ILLUSTRATION

Executed using javac in linux terminal