Code Below:


import java.util.*;
class convertgrouping
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        System.out.println("Enter an octal no.");
        int num=s.nextInt();
        String t,str="",hex="";int deci=0,r,i,len;
        int arr[]={0,1,2,3,4,5,6,7};
        String arr2[]={"000","001","010","011","100","101","110","111"};
        String arr3[]={"F","E","D","C","B","A"};
        while (num>0)
        {
            r=num%10;
            str=arr2[r]+str;
            num=num/10;
        }
        len=str.length();
        if (len%4!=0)
        {
            for (i=1;i<=4-(len%4);i++)
            str="0"+str;
        }
        System.out.println("No. in binary="+str);
        len =str.length();
        for (i=0;i0)
            {
                int rem=temp%10;
                deci=deci+rem*(int)Math.pow(2,k++);
                temp=temp/10;
            }
            System.out.println("Group "+(i+1)+"="+deci);
            if (deci>=10)
            hex=hex+arr3[15-deci];
            else
            hex=hex+Integer.toString(deci);
            deci=0;
        }
        System.out.println("Converted no.="+hex);
    }
}