Convert decimal to binary and then convert to inverse of binary by changing 0 to 1 and 1 to 0
public class test { public static void main(String[] args) { System.out.println(getIntegerComplement(50)); } static int getIntegerComplement(int n) { String binary = ""; String rev =""; StringBuilder sb = new StringBuilder(); int k; while(n>0){ int r= n%2; binary = r+binary; n= n/2; } System.out.println("binary for n is::"+ binary); for(int i=0; i<binary.length(); i++) { sb.append(binary.charAt(i)); if(sb.charAt(i)=='0') { sb.replace(i, i+1, "1"); }else{ sb.replace(i, i+1, "0"); } } rev = sb.toString(); k = Integer.parseInt(rev); int decimal=0; int power=0; int l=k; while(l>0) { int tmp = l%10; decimal = (int) (decimal+ tmp*Math.pow(2, power)); l=l/10; power++; } System.out.println("decimal of inverse is:::"+ decimal); System.out.print("inverse binary of n is:::")...