View Single Post
Old Nov 8th, 2007, 6:16 AM   #1
gam3r
Newbie
 
Join Date: Jun 2005
Location: London, England
Posts: 24
Rep Power: 0 gam3r is on a distinguished road
Decimal to binary help

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
__________________
biggest NOOB ever :P
gam3r is offline   Reply With Quote