In this assignment you will be generating an informative invoice for the AM Coffee shop where the tax is dependent on the date of
In this assignment you will be generating an informative invoice for the AM Coffee shop where the tax is dependent on the date of the month the order is placed. Here's what your program will do: Print a greeting "Welcome to AM Coffee Shop" Print the company logo "AM" in large letters spanning at least 6 lines Ask the user for the day of the month (an integer between 1 and 31 - for simplicity we will assume all months are 31 days long) Assume user enters valid data. Ask the user for the quantity of coffee in pounds. Assume user can enter a fractional value (See the sample runs below). Read both the values and show a table showing costs (cost of coffee, shipping cost, tax amount and total cost) for three days: today, tomorrow and the day- after based on the following policy. . Coffee shop charges $9.50 per pound Shipping charges are $0.65 per pound + $2.50 fixed cost for overhead Tax rate is variable depending on the day of the month. Tax percentage is number of days remaining in the month (assuming all months are 31 days long) divided by 5. e.g. on the 5th day of the month, the tax rate is (31-5)/5 = 5.2 %. Tax is applied only to the cost of coffee Print all the quantities rounded to maximum of 2 decimal places. . (Note that because floating number representation is not precise, your calculations may result in numbers that are different from the sample runs by a couple of cents.) Sample runs: Sample run with class constant COL_WIDTH set to 10: ---jGRASP exec: java CoffeeShopInvoice Welcome to AM Coffee shop AM /------\ *** 1 Enter the date: 3 Enter the pounds of coffee: 25.5 ** Shipping Cost: $19.08 Cost of coffee: $242.25 Date L 3 $13.57 4 === Tax 5 $13.08 ** $12.6 **** Total $274.9 $274.41 $273.93 ----jGRASP: operation complete. Sample run with class constant COL_WIDTH set to 15: Welcome to AM Coffee shop AM *** Enter the date: 8 Enter the pounds of coffee: 120.5 -jGRASP exec: java CoffeeshopInvoice ****** Shipping Cost: $80.83 Cost of coffee: $1144.75 ****** *******: ======= ======== ======== Date ==== ===== L 8 9 10 ******** $52.66 $50.37 ==== ====== =============== Tax $48.08 -jGRASP: operation complete. == ********* == ******: ********* *********** Total ==== $1278.24 ==== $1275.95 ====== $1273.66 =========== You will write a complete class called CoffeeShopInvoice in a file called Coffee ShopInvoice.java and upload the file. This class should have the following: 1. COL_WIDTH: a class constant that defines the width of the columns of the invoice being printed. You should use this constant all through the code so that changing this value and re-compiling and running the program will change the width of the columns keeping proper alignment of the table headers and numbers. Initialize it to 15. 2. padString method that accepts two parameters: a String and an integer representing a length. The method should pad the parameter string with spaces until its length is the given length and return the padded string. For example, padstring ("hello", 8) should return " hello". If the string's length is already at least as long as the length parameter, your method should return the original string. (Same as BJP Exercise 3.17) 3. printLogo method that takes no parameters and prints the logo of the coffee shop as shown in the sample runs above. Use the COL_WIDTH class constant to print the correct size separator lines. The width of the letters 'AM' of the logo will stay the same irrespective of the value of COL_WIDTH class constant. You don't have to use any for-loops in printing the logo. Just come up with a way to print the letters spanning at least 6 lines. 4. round To2Decimal method that accepts a double parameter and returns that number rounded to two decimal places. Hint: Math.round() method can be helpful here. 5. 6. calculate CostOfCoffee method that accepts the number of pounds ordered and returns the cost of coffee rounded to 2 decimal places. calculateShipping Cost method that accepts the number of pounds ordered and returns the shipping cost rounded to 2 decimal places. 7. calculateTax method that accepts the date and cost of coffee as parameters. It calculates the tax rate, applies it to the cost of coffee and returns the tax amount rounded to 2 decimal places. 8. printInvoice method that accepts two parameters: the date as an integer and the number of pounds as a double. This method will use other helper methods described above to calculate the different amounts to be printed in the invoice for the three days: today, tomorrow and the day after. It prints the shipping cost and the cost of coffee. The tax rate changes every day as described above. This method print the date, tax amount and the total (cost of coffee, tax and shipping cost) for that date in a tabular form as shown above. Use the COL_WIDTH class constant, padString methods to get the column headers and the numbers right- aligned and formatted in a tabular form as shown in the sample runs. 9. main method that prompts the user to enter the date and the number of pounds and calls other methods to get the logo and the invoice table printed. 10. Ensure your program output matches the format shown in the sample runs. 11. Requirements: 1. If the value of COL_WIDTH is changed and the program is re-compiled and re-run, the tables should maintain the alignment of separator line, headers and numbers. 2. It is not enough that your program produces required output, your program should write and use helper methods as described above. The methods should be declared with correct parameter(s) and return type.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Lets break our solution into three portions starting with the logic of logo Its tricky if you trying to code it with loop but thats not necessary so S...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