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

1. Member
Join Date
Oct 2012
Posts
2
Rep Power
0

## 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)

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

3. Member
Join Date
Oct 2012
Posts
2
Rep Power
0

## 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. Senior Member
Join Date
Oct 2012
Posts
108
Rep Power
0

## 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

6. Member
Join Date
Oct 2012
Posts
13
Rep Power
0

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

#### Posting Permissions

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