Conversion of a number from BINARY to OCTAL
Write a java program to accept a binary number and convert to decimal number.
import java.util.*;
public class bitode {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("ENTER A BINARY NUMBER : ");
int n=sc.nextInt();
double s=0;
int c=0;
while(n>0)
{
int d=n%10;
s=s+Math.pow(2,c)*d;
c++;
n=n/10;
}
System.out.println("DECIMAL VALUE : " + s);
}
}
TO FIND OUTPUT : CLICK >> https://onecompiler.com/java/3ydv3e5fr