Results 1 to 8 of 8
Like Tree2Likes
  • 2 Post By PhHein

Thread: need help writing code for a java program, im beginner

  1. #1
    kittykat0953 is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Exclamation need help writing code for a java program, im beginner

    this is the problem and i have to do a program for it. can anyone help me. thankn ou

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

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: need help writing code for a java program, im beginner

    What do you need help with? Nobody will code it for you.
    KevinWorkman and zjderr like this.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    kittykat0953 is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default Re: need help writing code for a java program, im beginner

    i know. i just need help on how to do it. do i use the int variable , double, or string.
    i have

    public class Land

    {
    public static void main(String [] args)
    {
    do i assign strings here and then use the system out print below to get what i want to output

    System.out.println(

  4. #4
    mbschutlz97 is offline Member
    Join Date
    Jan 2014
    Posts
    30
    Rep Power
    0

    Default Re: need help writing code for a java program, im beginner

    Java Code:
    public class LandCalculation{
    	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);
    	}
    }

  5. #5
    kittykat0953 is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default Re: need help writing code for a java program, im beginner

    thank you @ mbs. can you explain a bit how you did that if you don't mind. when you use the double and int do they have to be different i cant just uuse double or int. i have to use both

    do i have to add more to this program

  6. #6
    mbschutlz97 is offline Member
    Join Date
    Jan 2014
    Posts
    30
    Rep Power
    0

    Default Re: need help writing code for a java program, im beginner

    so basically ints and doubles are primitive data types... ints can only hold whole numbers though and doubles can hold decimals... google primitive data types to learn more :)

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default Re: need help writing code for a java program, im beginner

    Quote Originally Posted by mbschutlz97 View Post
    Java Code:
    public class LandCalculation{
    	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);
    	}
    }
    Please don't spoonfeed the OP.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    mbschutlz97 is offline Member
    Join Date
    Jan 2014
    Posts
    30
    Rep Power
    0

    Default Re: need help writing code for a java program, im beginner

    Quote Originally Posted by JosAH View Post
    Please don't spoonfeed the OP.

    kind regards,

    Jos
    my bad

Similar Threads

  1. java code help please beginner
    By aaden1 in forum New To Java
    Replies: 5
    Last Post: 10-29-2012, 06:03 PM
  2. Need help with beginner java array program??
    By sd1234 in forum New To Java
    Replies: 3
    Last Post: 01-31-2012, 08:24 AM
  3. Help with beginner Java program? Boolean?
    By katiebear128 in forum New To Java
    Replies: 20
    Last Post: 09-30-2011, 06:35 PM
  4. JAVA Beginner - Simple Program help
    By Logik22 in forum New To Java
    Replies: 13
    Last Post: 07-15-2011, 02:44 PM
  5. Replies: 8
    Last Post: 06-06-2011, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •