Pls tell me why this code is wrong

import java.util.;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner x=new Scanner(System.in);
System.out.println(“enter a binary no.”);
int a=x.nextInt();
int i=0;
double s=0;
int r;
while(a!=0)
{
r=a%10;
a=a/10;
double p=Math.pow(2,i);
s=s+r
p;
i++;
}
System.out.println(s);

}

}

Hi Deepak,
First you don’t have to print a statement before taking input. Secondly, you have to first take the value of n from user i.e. number of binary numbers and then take n inputs and print their respective decimal number. Also you don’t have to use double data type instead use int.

First take no of binary no’s as input. Then take input for binary no.