Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: hi, beginner. need help with code

1. ## hi, beginner. need help with code

hi i am a total beginner at java code.
i am trying to write a program for this problem.

Land Calculation

One acre of land is equivalent to 43,560 square feet. Write a program
that calculates the number of square feet in a tract of land with 3.5
acres. Hint: Multiply the size of the tract of land (in acres) by the
number of square feet in an acre to get the number of square feet in
the tract.

a) You must have a variable called nrAcres where you will store the
number of acres in the track.

b) Output must look as follows:

Size of land in acres: 3.5
Size of land in square feet: 152460

c) if the value of the variable nrAcres is changed the output should
change accordingly. In other words: it would be wrong to have the
following statement:

System.out.println("Size of land in square feet: 152460");

previous statement will print the correct output but will not change
if you change the value of nrAcres.

this is what i got so far

public class Land
{
public static void main(String[] args){
double nrAcres = 3.5;
int feetInAcre = 43560;
double feetInTract = nrAcres * feetInAcre;
System.out.println("Size of land in acres: " + nrAcres + "\nSize of land in square feet: " + feetInTract);
}
}

i tried to compile it but it says

error: class names, Land, are only accepted if annotation is explicitly requested 1 error

what is wrong with my code

2. ## Re: hi, beginner. need help with code

Hi,

I think you missed ".java" at the time compilation. Try to complile like this "javac Land.java" and run the program "java Land"

Still you have any difficulties post here.we are happy to help you

thanks,

3. ## Re: hi, beginner. need help with code

Crossposted: need help writing code for a java program, im beginner
The code was spoonfed.

4. ## Re: hi, beginner. need help with code

Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.