Question
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
- 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 takes the number of trees purchased, their height, and the delivery information to print a customer 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 |
Your program should ask the user for the following information:
-Number of Trees the customer would like to purchase
-Tree height to the nearest foot (have them enter it as a whole number so no fractional tree heights)
-If the trees will be delivered
-Ask if the trees 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 the tree cost, delivery cost and total cost and display an invoice for the user (see below).
Your program will need the following variables (note that these are suggested variables (and you may need some additional variables besides these)), if you figured out a way to do the program using different variables that is OK):
- a Scanner type variable named keyboard to read in user input (or you can use Dialog Boxes)
- You can use printf to format the values (or use DecimalFormat if you wish)
- a int type variable named forDelivery to hold the value 1 to indicate that Yes the trees will be delivered or to hold the value 0 to indicate that No the trees wont be delivered (do NOT use a char as it will cause problems I havent showed you how to fix yet). The user should be prompted to enter 1or 0 to indicate their choice regarding delivery.
- a int type variable named numTrees to hold user input on the number of trees they want to purchase (the user cannot buy fractional treed)
- a double or int type (remember for simplicity we said assume the user enters a whole number but you may use double if you would like) variable named treeHeight to hold user input on the height of the trees they want to purchase (remember all trees purchased are assumed to be the same height)
- a double type variable named singleTree to hold the cost of one tree
- a double type variable named treeCost to hold the total cost of the all trees purchased
- (treeCost = numTrees * cost for one tree (singleTree variable above) at the treeHeight the customer is purchasing trees at)
- HINT: You will need to use an if-else-if statement to determine the cost of one tree based on its height
- a double type variable named deliveryCost to hold the delivery costs (if any) for the trees
- HINT: Initialize the variable deliveryCost to zero in case there are no delivery costs
- HINT: You will need an if-else statement to determine delivery charges for the case when numTrees is less than 5 and the case when numTrees is greater than or equal to 5
- a double type variable named totalCharges to hold the total charges for the trees
- (totalCharges = treeCost + deliveryCost)
Your program should output something similar to the following (use System.out.println() and the escape sequences you learned as well as spaces to format the character data and use the Decimal Formatter class or printf to format the numeric data):
Green Fields Landscaping
Evergreen Tree Invoice
4 Trees at 99.00 each : $ 396.00
Delivery Charge: $ 0.00
-----------
TOTAL: $ 396.00
Make sure and test your program for cases with delivery, cases without delivery and with cases different numbers of trees.
HINT: This is a program where writing pseudocode before you start will make your programming easier.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started