Convert Decimal to Octal Java Program

Sharing is healthy !!

Today let us learn how to convert decimal to octal java program. Below program is similar to decimal to hexadecimal conversion program. Let’s get into it,

Example: Convert Decimal to Octal Java Program

Convert Decimal to Octal Java Program

Also Read – Convert Decimal to Binary Java Example

import java.util.Scanner;

public class Decimal_to_Octal {

Scanner sc;
int number;

void get_Value(){
System.out.println("Conversion from Decimal to Octal");
sc = new Scanner(System.in);
System.out.println("Please enter a decimal number: ");
number = Integer.parseInt(sc.nextLine());
}

void to_Convert(){
String octal = Integer.toOctalString(number);
System.out.println("The converted octal value is: " + octal);
}

public static void main(String[] args) {

Decimal_to_Octal dto = new Decimal_to_Octal();
dto.get_Value();
dto.to_Convert();
}
}

Output:

Conversion from Decimal to Octal
Please enter a decimal number: 100
The converted octal value is: 144

Sharing is healthy !!

Leave a Reply

Your email address will not be published.