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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: hi, beginner. need help with code

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    19
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question 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. #2
    Member Ganeprog's Avatar
    Join Date
    Jan 2014
    Location
    Chennai,India
    Posts
    80
    My Mood
    Love
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default 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. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: hi, beginner. need help with code

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

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default 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.

    We'll help you with your code but may be less eager to help you with code you've just copied from somewhere else.

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    23
    My Mood
    Mellow
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: hi, beginner. need help with code

    Please compile your code and run it.

Similar Threads

  1. Help with beginner code
    By KSB Dad in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 13th, 2013, 07:31 AM
  2. Beginner code
    By Skybear in forum What's Wrong With My Code?
    Replies: 11
    Last Post: December 1st, 2012, 07:15 PM
  3. Hello, I'm a beginner and I really need help for my code..
    By aimEhjO in forum Member Introductions
    Replies: 10
    Last Post: August 4th, 2012, 09:22 AM
  4. Need Help with code ...beginner
    By Envious1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 19th, 2012, 08:52 AM
  5. Beginner - Help with my code.
    By eddross in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2010, 09:30 AM