import java.util.Scanner;
public class jeremycattau_Octal
{
public static void main ( String args[] )
{
Scanner input = new Scanner (System.in);
int dig1 = 0;
int dig2 = 0;
int dig3 = 0;
int dig4 = 0;
int dig5 = 0;
int octal, remain;
System.out.println("Please enter a number between 0 and 32767 to convert:");
octal = input.nextInt();
if (octal == 32767)
dig5 = octal / 4096;
remain = octal % 4096;
dig4 = remain / 512;
remain = remain % 512;
dig3 = remain / 64;
remain = remain % 64;
dig2 = remain / 8;
remain = remain % 8;
dig1 = remain;
System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
else if (octal >= 4096)
dig4 = octal / 512;
remain = remain % 512;
dig3 = remain / 64;
remain = remain % 64;
dig2 = remain / 8;
remain = remain % 8;
dig1 = remain;
System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
else if (octal >= 512)
dig3 = octal / 64;
remain = remain % 64;
dig2 = remain / 8;
remain = remain % 8;
dig1 = remain;
System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
else if (octal >= 64)
dig2 = octal / 8;
remain = remain % 8;
dig1 = remain;
System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
else if (octal >= 8)
dig1 = octal % 8;
System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
else System.out.printf("Your integer number %d is %d%d%d%d%d in octal.\n", octal, dig5, dig4, dig3, dig2, dig1);
}
}