Results 1 to 7 of 7
  1. #1
    kristina5193 is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default can someone help me with this program, or at least get me started on it please

    Green Fields Landscaping Company sells evergreen trees which are priced by height. Customers have a choice of purchasing a tree and taking it home with them or purchasing a tree and having it delivered. Write a program that asks the user the number of trees purchased, the height of the trees, and if they want the trees delivered. Based on that information the program should then generate an invoice. Assume that ALL the trees purchased by a customer are the same height.

    Tree Pricing Information

    Under 3 Feet Tall


    39.00 (tax included)

    3 to 5 Feet Tall


    69.50 (tax included)

    6 to 8 Feet Tall


    99.00 (tax included)

    Over 8 Feet Tall


    199.50 (tax included)

    Additional Fee for Delivery


    If the number of trees purchased is less than five the delivery fee is 10.00 * the number of trees purchased

    If the number of trees purchased is five or more the delivery fee is 50.00


    OH AND I CANT USE CHAR!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: can someone help me with this program, or at least get me started on it please

    I'm sure you don't expect someone to do your homework for you, as that would be cheating. Show your best efforts, ask a specific question* that lets us know where you're stuck and you're sure to get help here.

    * on the lines of How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kristina5193 is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default Re: can someone help me with this program, or at least get me started on it please

    import java.util.Scanner;
    import java.text.DecimalFormat;

    public class greenfields
    {
    public static void main(String[] args)
    {
    Scanner keyboard = new Scanner(System.in);

    String choice;
    int forDelivery;
    int numTrees;
    int treeHeight;
    double singleTree;
    double treeCost;
    double deliveryCost;
    double totalCharges;

    System.out.println("How many trees do you want to purchase?");
    numTrees = keyboard.nextLine(numTrees);
    System.out.println("Enter the height of trees you want to purchase.");
    treeHeight= keyboard.nextLine();
    System.out.println("Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No.");
    forDelivery=keyboard.nextLine();
    if(forDelivery== 'Y')

    if(numTrees <5)
    forDelivery=10.00*numTrees;
    else if (numTrees >=5)
    forDelivery=50;

    totalTreeCost = numTrees * treeCost;


    if (treeHeight < 3) ;
    treeCost = numTrees * 39.00;
    System.out.println( numTrees+ "Trees at" + TreeCost + "each" + TotalTreeCost

    else (treeHeight <= 5);
    treeCost =numTrees * 69.50;
    else (treeHeight <= 8);
    treeCost =numTrees * 99.00;
    else(treeHeight >=9);
    treeCost= numTrees * 199.50

    totalTreeCost = numTrees * treeCost;

    okay i got to this point, now im confused on how to exactly do the yes or no part and also on the decimals..

  4. #4
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: can someone help me with this program, or at least get me started on it please

    It will make your job a lot easier if you get an IDE to help you with this... there are a lot of issue that Eclipse will point out to you immediately.

    1. Forget about the polish (DecimalFormat) until you have working code!
    2. Scanner.nextLine() returns a String ... Integer.parseInt() and Double.parseDouble() may help... but there are some issues with those as well, similar to Scanner.nextInt() if someone enters "sammich"
    3. else is else! else if is different ;)
    4. if (int == char) ... this is really not what you want. HINT (int)'Y' = 89

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: can someone help me with this program, or at least get me started on it please

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    DrummondAW is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: can someone help me with this program, or at least get me started on it please

    I'm learning Java and thought this sounded like a good exercise. Here is my code: [Moderator edit: link removed]

    Please don't cheat by using my code - use it as reference if you'd like. You'll only hurt yourself down the road.

    I second getting Eclipse as well. It's free, quick to install and has auto-complete to help with coding purposes.
    Last edited by DarrylBurke; 10-27-2012 at 03:30 PM. Reason: Removed link

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: can someone help me with this program, or at least get me started on it please

    1. This is a forum, not a place to exchange off-forum information that doesn't benefit the community.

    2. Please don't deny others the chance to learn by providing a complete solution, on or off the forum.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Getting Started
    By AndrewM16921 in forum JDBC
    Replies: 1
    Last Post: 10-27-2011, 01:54 PM
  2. Need help getting started on a program
    By LJ1423 in forum New To Java
    Replies: 2
    Last Post: 04-09-2011, 11:01 AM
  3. Autostart if program isn't started
    By Kruptein in forum AWT / Swing
    Replies: 0
    Last Post: 08-07-2009, 07:03 PM
  4. Get me started?
    By neworlbush25 in forum New To Java
    Replies: 4
    Last Post: 03-26-2009, 05:16 PM
  5. Replies: 3
    Last Post: 12-31-2008, 05:57 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
  •