Example: Create variables: monthlySales Prompt user for their monthly sales Wait for user and then save...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
• • Example: Create variables: monthlySales Prompt user for their monthly sales Wait for user and then save user input in variable monthlySales If monthlySales variable > 60000 ⚫ -Display message to user: You have earned a $1000 bonus Homework #4 - Based on Chapter 3 (Parts 1 and 2 lectures) 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 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 O for No. -Do NOT use chars for input - your program will break due to some things I haven't shown you yet and you won't pass the Hypergrade test cases. 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 some of these are required and some of 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 (remember Scanner is REQUIRED, no Dialog Boxes for this one) • a DecimalFormat type variable named formatter to format output (DecimalFormat is REQUIRED, no System.out.printf) ⚫ an 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 won't be • delivered (do NOT use a char as it will cause problems I haven't showed you how to fix yet). The user should be prompted to enter 1 or 0 to indicate their choice regarding delivery. an int type variable named numTrees to hold user input on the number of trees they want to purchase (the user cannot buy fractional trees) • a int type variable named treeHeight (remember for simplicity we said assume the user enters a whole number for the tree height) 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 single Tree to hold the cost of one tree • a double type variable named treeCost to hold the total cost of the all trees purchased • (treeCost = num Trees * cost for one tree (single Tree 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 delivery Cost 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 num Trees is greater than or equal to 5 • a double type variable named totalCharges to hold the total charges for the trees (totalCharges = treeCost + deliveryCost) Any other variables you need Your program should output an invoice in the following format (look at the output in the "view required solution" link for exact output): Green Fields Landscaping Evergreen Tree Invoice 4 Trees at 99.00 each: $396.00 Delivery Charge: TOTAL: $ 0.00 $ 396.00 Make sure and test your program for cases with delivery, cases without delivery and with cases different numbers of trees. Test Case 1 How many trees do you want to purchase? \n 3 ENTER Enter the height of trees you want to purchase. \n 9 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 3 Trees at 199.50 each: $598.50 \n Delivery Charge: \t $30.00 \n \t \t \t \n TOTAL: \t \t \t |$628.50 \n Test Case 2 How many trees do you want to purchase? \n 7 ENTER Enter the height of trees you want to purchase. \n 2 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 7 Trees at 39.00 each: $273.00 \n Delivery Charge: \t $50.00 \n \t \t \t \n TOTAL: \t \t \t $323.00 \n Test Case 3 How many trees do you want to purchase? \n 1 ENTER Enter the height of trees you want to purchase. \n 6 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 1 Trees at 99.00 each: $99.00 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $99.00 \n Test Case 4 How many trees do you want to purchase? \n 8 ENTER Enter the height of trees you want to purchase. \n 3 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 8 Trees at 69.50 each: $556.00 \n Delivery Charge: \t $50.00 \n \t \t \t \n TOTAL: \t \t \t $606.00 \n Test Case 5 How many trees do you want to purchase? \n 6 ENTER Enter the height of trees you want to purchase. \n 5 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 6 Trees at 69.50 each: $417.00 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $417.00 \n Test Case 6 How many trees do you want to purchase? \n 1 ENTER Enter the height of trees you want to purchase. \n 10 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 1 Trees at 199.50 each: $199.50 \n Delivery Charge: \t $10.00 \n \t \t \t \n TOTAL: \t \t \t $209.50 \n Test Case 7 How many trees do you want to purchase? \n 5 ENTER Enter the height of trees you want to purchase. \n 11 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 5 Trees at 199.50 each: $997.50 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $997.50\n • • Example: Create variables: monthlySales Prompt user for their monthly sales Wait for user and then save user input in variable monthlySales If monthlySales variable > 60000 ⚫ -Display message to user: You have earned a $1000 bonus Homework #4 - Based on Chapter 3 (Parts 1 and 2 lectures) 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 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 O for No. -Do NOT use chars for input - your program will break due to some things I haven't shown you yet and you won't pass the Hypergrade test cases. 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 some of these are required and some of 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 (remember Scanner is REQUIRED, no Dialog Boxes for this one) • a DecimalFormat type variable named formatter to format output (DecimalFormat is REQUIRED, no System.out.printf) ⚫ an 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 won't be • delivered (do NOT use a char as it will cause problems I haven't showed you how to fix yet). The user should be prompted to enter 1 or 0 to indicate their choice regarding delivery. an int type variable named numTrees to hold user input on the number of trees they want to purchase (the user cannot buy fractional trees) • a int type variable named treeHeight (remember for simplicity we said assume the user enters a whole number for the tree height) 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 single Tree to hold the cost of one tree • a double type variable named treeCost to hold the total cost of the all trees purchased • (treeCost = num Trees * cost for one tree (single Tree 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 delivery Cost 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 num Trees is greater than or equal to 5 • a double type variable named totalCharges to hold the total charges for the trees (totalCharges = treeCost + deliveryCost) Any other variables you need Your program should output an invoice in the following format (look at the output in the "view required solution" link for exact output): Green Fields Landscaping Evergreen Tree Invoice 4 Trees at 99.00 each: $396.00 Delivery Charge: TOTAL: $ 0.00 $ 396.00 Make sure and test your program for cases with delivery, cases without delivery and with cases different numbers of trees. Test Case 1 How many trees do you want to purchase? \n 3 ENTER Enter the height of trees you want to purchase. \n 9 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 3 Trees at 199.50 each: $598.50 \n Delivery Charge: \t $30.00 \n \t \t \t \n TOTAL: \t \t \t |$628.50 \n Test Case 2 How many trees do you want to purchase? \n 7 ENTER Enter the height of trees you want to purchase. \n 2 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 7 Trees at 39.00 each: $273.00 \n Delivery Charge: \t $50.00 \n \t \t \t \n TOTAL: \t \t \t $323.00 \n Test Case 3 How many trees do you want to purchase? \n 1 ENTER Enter the height of trees you want to purchase. \n 6 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 1 Trees at 99.00 each: $99.00 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $99.00 \n Test Case 4 How many trees do you want to purchase? \n 8 ENTER Enter the height of trees you want to purchase. \n 3 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 8 Trees at 69.50 each: $556.00 \n Delivery Charge: \t $50.00 \n \t \t \t \n TOTAL: \t \t \t $606.00 \n Test Case 5 How many trees do you want to purchase? \n 6 ENTER Enter the height of trees you want to purchase. \n 5 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 6 Trees at 69.50 each: $417.00 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $417.00 \n Test Case 6 How many trees do you want to purchase? \n 1 ENTER Enter the height of trees you want to purchase. \n 10 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n 1 ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 1 Trees at 199.50 each: $199.50 \n Delivery Charge: \t $10.00 \n \t \t \t \n TOTAL: \t \t \t $209.50 \n Test Case 7 How many trees do you want to purchase? \n 5 ENTER Enter the height of trees you want to purchase. \n 11 ENTER Would you like the trees delivered? Enter 1 for Yes, Enter 0 for No. \n ENTER Green Fields Landscaping \n Evergreen Tree Invoice \n \n 5 Trees at 199.50 each: $997.50 \n Delivery Charge: \t $0.00 \n \t \t \t \n TOTAL: \t \t \t $997.50\n
Expert Answer:
Answer rating: 100% (QA)
This is a sample program that calculates and generates an invoice based on the user input for purchasing evergreen trees from Green Fields Landscaping ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
A regular language is a language that can be defined by a regular expression. 0 2 . 1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Calculate the directional derivative in the direction of v at the given point. Remember to use a unit vector in your directional derivative computation. g(x, y, z) = xe-y, v = (1, 1, 1), P = (1,2,0)
-
Cadux Candy Company's income statement for the year ended December 31, 2018, reported interest expense of $2 million and income tax expense of $12 million. Current assets listed in its balance sheet...
-
Researchers in retail studies wanted to find out how children and adults react to companies pricing tactics. They looked at a random sample of 44 10th-grade students, a random sample of pretested...
-
As competition in the retail market began to heat up, it became necessary to find ways to motivate the sales staff of Mayfield Department Stores to increase sales. Therefore, a motivational program...
-
Bob Hansen opens a retail store on January 1, 2013. Hansen invests $50,000 for all of the common stock of the firm. The store borrows $40,000 from a local bank. The store must repay the loan with...
-
Application (Cont.). A recent paper of mine looks at the relationship between retirement savings at age 30 and student loan debt at age 25. Four observations from the data are below. All numbers are...
-
Prepare a December 31 trial balance for Jindal Company using the following information and fill in the missing amount for Equipment (assume all data are correct). Cash Accounts payable Services...
-
You are designing an IP addressing system for a large home that has IP enabled end-systems (appliance, light switches, security systems, heating/coding systems, and video cameras). This network is...
-
Details The following questions will give you a chance to self-evaluste, think about what you've been learning in this course, and drave conclusions about how you can apply your communication skill...
-
3 VTV In has the following financial statements for 3021 Sales VTY 2021 fame Statement Les Cost of goods sold Less Depreciation Less Interest paid Taxable income $25,800.00 15,600 00 6.000.00...
-
Summarise the management of project human resources needed to build a community garden in the city cbd. - Specify the numbers and required skill levels of personnel for each work activity - Describe...
-
1) Determine the shear stress and shear-flow distribution over the cross-section of the beam shown in the figure below. Assume the web is ineffective in resisting bending and the stringer areas to be...
-
Question Using the Proof for Perpetuity formula shown below, solve y = x + 2 x + 3 x + 4x + where x <1 Proof for Perpetuity Formula: 3 n y=x+x+x + x multiply ean by x 2 3 = X + X + Xx 4 . + x...
-
Bloggs Engineering has recently carried out a detailed cost analysis of its machinery. Having studied past records of the maintenance costs and depreciation of its machines, the company has found...
-
Privitera and Freeman (2012) constructed a scale to measure or estimate the daily fat intake of participants; the scale was called the estimated daily intake scale for fat (EDIS-F). To validate the...
-
a. Create an Alien class. Include at least three protected data members of your choice, such as the number of eyes the Alien has. Include a constructor that requires a value for each data field and a...
-
a. Create a class named Sandwich. Data fields include a String for the main ingredient (such as tuna), a String for bread type (such as wheat), and a double for price (such as 4.99). Include methods...
-
In Java, methods must include all of the following except _____________. a. A call to another method b. A declaration c. Curly braces d. A body
-
Management is considering three alternatives to satisfy an urgent need. Each of the alternatives will completely satisfy the need, so no combinations have to be considered. The first costs, operating...
-
Consider the following cash flow profile and assume MARR is 10 percent/year and the finance rate is 4 percent/year. a. Determine the MIRR for this project. b. Is this project economically attractive?...
-
Consider the following cash flow profile and assume MARR is 10 percent/year and the finance rate is 4 percent/ year. a. Determine the MIRR for this project. b. Is this project economically...
Study smarter with the SolutionInn App