Green Fields Landscaping Company Sells Evergreen Trees Priced Height Customers Choice Purc Q43894168
- Green Fields Landscaping Company sells evergreen trees whichare priced by height. Customers have a choice of purchasing a treeand taking it home with them or purchasing a tree and having itdelivered. Write a program that takes the number of treespurchased, their height, and the delivery information to print acustomer invoice. Assume that all the trees purchased by acustomer 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 deliveryfee is 10.00 * the number of trees purchased
If the number of trees purchased is five or more the deliveryfee is 50.00
Your program should ask the user for the followinginformation:
-Number of Trees the customer would like topurchase
-Tree height to the nearest foot (have them enterit as a whole number – so no fractional tree heights)
-If the trees will be delivered
-Ask if thetrees will be delivered using the following prompt:
“Will the trees be delivered? Enter 1 for Yes, Enter 0 for No.”
Once your program has the user input it should calculate thetree cost, delivery cost and total cost and display an invoice forthe user (see below).
Your program will need the following variables (notethat these are suggested variables (and you may need someadditional variables besides these)), if you figured out a way todo the program using different variables that is OK):
- a Scanner type variable named keyboard to read in userinput (or you can use Dialog Boxes)
- You can use printf to format the values (or use DecimalFormatif you wish)
- a int type variable named forDelivery to hold thevalue 1 to indicate that Yes the trees will be delivered or to holdthe value 0 to indicate that No the trees won’t be delivered (doNOT use a char as it will cause problems I haven’t showed you howto fix yet). The user should be prompted to enter 1or 0 to indicatetheir choice regarding delivery.
- a int type variable named numTrees to hold user inputon the number of trees they want to purchase (the user cannot buyfractional treed)
- a double or int type (remember for simplicity we said assumethe user enters a whole number but you may use double if you wouldlike) variable named treeHeight to hold user input on theheight of the trees they want to purchase (remember all treespurchased are assumed to be the same height)
- a double type variable named singleTree to hold thecost of one tree
- a double type variable named treeCost to hold thetotal cost of the all trees purchased
- (treeCost = numTrees * cost for one tree(singleTree variable above) at the treeHeight thecustomer is purchasing trees at)
- HINT: You will need to use an if-else-if statement to determinethe cost of one tree based on its height
- a double type variable named deliveryCost to hold thedelivery costs (if any) for the trees
- HINT: Initialize the variable deliveryCost to zero incase there are no delivery costs
- HINT: You will need an if-else statement to determine deliverycharges for the case when numTrees is less than 5 and thecase when numTrees is greater than or equal to 5
- a double type variable named totalCharges to hold thetotal charges for the trees
- (totalCharges = treeCost + deliveryCost)
Your program should output something similar to thefollowing (use System.out.println() and the escapesequences you learned as well as spaces to format the characterdata and use the Decimal Formatter class or printf to format thenumeric data):
Green Fields Landscaping
Evergreen Tree Invoice
4 Trees at 99.00 each : $396.00
DeliveryCharge: $ 0.00
———–
TOTAL: $ 396.00
Make sure and test your program for cases with delivery, caseswithout delivery and with cases different numbers of trees.
HINT: This is a program where writing pseudocodebefore you start will make your programming easier.
Expert Answer
Answer to Green Fields Landscaping Company sells evergreen trees which are priced by height. Customers have a choice of purchasin…
OR