1import java.util.Scanner;
2public class DecimalToOctalUsingWhileLoop
3{
4 public static void main(String[] args)
5 {
6 int decimal;
7 Scanner sc = new Scanner(System.in);
8 System.out.println("Please enter decimal number: ");
9 decimal = sc.nextInt();
10 int octalNumber = 0, a = 1;
11 while(decimal > 0)
12 {
13 octalNumber += a * (decimal % 8);
14 decimal = decimal / 8;
15 a = a * 10;
16 }
17 System.out.println("Octal number is: " + octalNumber);
18 sc.close();
19 }
20}