Code Below:


import java.util.*;
class Conversion
{
    public static void main()
    {
        Scanner s= new Scanner(System.in);
        System.out.println("Enter a no. in base 10");
        int n=s.nextInt();
        System.out.println("Convert it into:\n1. Binary\n2. Octal\n3. Hexa Decimal");
        int ch=s.nextInt();
        int r,temp=n;
        String h=" ";
        String str[]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
        
        switch (ch)
        {
            case 1:
            while (temp>0)
            {
                r=temp%2;
                h=str[r]+h;
                temp=temp/2;
            }
            break;
            
            case 2:
            while (temp>0)
            {
                r=temp%8;
                h=str[r]+h;
                temp=temp/8;
            }
            break;
            
            case 3:
            while (temp>0)
            {
                r=temp%16;
                h=str[r]+h;
                temp=temp/16;
            }
            break;
            
            default:System.out.println("Wrong Choice");
        }
        System.out.println("No. in Base 10="+n);
        System.out.println("Converted No.="+h);
    }
}