I'm trying to code a program in java which converts decimal to binary but i keep getting this error upon compile:
Quote:
Q1.java:11: 'class' or 'interface' expected
public static void main(String args[])
|
My code is
Quote:
import java.util.Scanner; //this program uses class scanner
public class Q1
{
public static int binTodec(String b)
{
System.out.println(Integer.toBinaryString(b));
}
}
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.println("Please enter the decimal number you want to convert to binary");
String b = input.nextLine();
binToDec(b);
}
|
Can anyone help?
Thanks