# can someone check this program to see if its ok. Im having some trouble compiling it.

• 11-13-2011, 04:28 PM
bulbul
can someone check this program to see if its ok. Im having some trouble compiling it.
Code:

```import java.util.Scanner; class FeetToMeters{         public static void main(String[] args) {                 Scanner input = new Scanner(System.in);         double feet, meters;                 System.out.println("Enter feet");         feet = input.nextDouble();         meters = (meters * 0.305);         System.out.println(feet + " feet is " + meters + " meters");     } }```
• 11-13-2011, 04:33 PM
Fubarable
Re: can someone check this program to see if its ok. Im having some trouble compiling
Hello, and welcome to Java-Forums.
Moderation: code tags added to your original post so we can read the code.

Please post your full error messages so we can know what the compiler is complaining about.

Also, look carefully at your code below. Are you sure that the second line is how you should be calculating meters?

Code:

```        feet = input.nextDouble();         meters = (meters * 0.305); // meters on both sides of this statement?```
• 11-13-2011, 04:34 PM
Cosmos
Re: can someone check this program to see if its ok. Im having some trouble compiling
the error is in line 14....

you are using meters without initializing it....

it should be something like-

meters=feet*0.305;
• 11-13-2011, 04:41 PM
bulbul
Re: can someone check this program to see if its ok. Im having some trouble compiling
oh thankyou

and another thing, when writing the formula are spaces meant to be left? like e.g 3 * 4 or should it be 3*4?
• 11-13-2011, 04:43 PM
Fubarable
Re: can someone check this program to see if its ok. Im having some trouble compiling
Quote:

Originally Posted by bulbul
and another thing, when writing the formula are spaces meant to be left? like e.g 3 * 4 or should it be 3*4?

I prefer to have spaces between math operators, and I think that this is also recommended in most Java programming style guidelines, but ultimately, your program style should be based on your instructor's requirements.
• 11-13-2011, 04:58 PM
bulbul
Re: can someone check this program to see if its ok. Im having some trouble compiling
ok thanks! :(handshake):