Question
Supermarket You and friends are opening a new Supermarket. To help with the item pricing, you will be developing a program to illustrate and sum
Supermarket
You and friends are opening a new Supermarket. To help with the item pricing, you will be developing a program to illustrate and sum the price of chosen items. Note that some items are taxable and have a sign of T. Others are non-taxable and have the sign of NT.As an opening sale, you will have a discount of 5% if the customer chooses a count up to 5 of the same item (such as 1, 2, 3, 4 or 5 cokes). The discount increases to 10% if a count from 6 up to and including 10 items, and 15% if the count is over 10 of the same item.
Put the following into Java with comments:
//Save the following program as Supermarket.java //Create the Supermarket class //Create the main method //Declare and assign variables for //count of items, item name, taxable, item price, cost, discount, tax, total, and //grand total //Use printf to print the header line used in the spreadsheet for this problem /* See Hints section - Using the same data used in the Lab l's spreadsheet: Set the count variable, the item variable, "T" or "NT" for the taxable variable and the item price variable. With these set, calculate the cost, discount, tax and total amounts. Be sure to Increment the grand total with the total amount. */ //Use printf to output the row of data with good alignment (See hints section) 1/Repeat the process 7 times as was done in the spreadsheet //As the last output row, output the grand total amount //End main method //End class Hints: //Determine and calculate discount example double discounti 0; if (counti 6) { discounti costi lt_6_discount; } else if(count1 11) { discounti costi * lt_11_discount; } else { discounti costi * discount; //Determine and calculate taxes example double tax1 = 0.0; if(taxablel.equalsIgnoreCase("T")) { tax1 (costi discountl) * tax; //Display output using printf example; Note: width in the format specifiers may need to be //adjusted slightly for the other rows System.out.printf("%d%15s%13s%12s%.2f%115%.2f%65%.2f%11s%.2f%55%.2f ", count1, "Pants", taxable1, "$", price1, "$", cost1, "$", discount1, "$", taxi, "$", totall); The output should look like this: Tax Total Count Item Taxable Price/Item Cost Discount =========== 4 Pants T $15.00 $60.00 $3.00 10 Apples NT $0.20 $2.00 $0.20 5 Pears NT $0.25 $1.25 $0.06 4 Quarts of Oil T $2.67 $10.68 $0.53 6 6 Dishes T $1.25 $7.50 $0.75 15 Silverware T $0.75 $11.25 $1.69 1 Laptop T $495.95 $495.95 $24.80 =============================================================================== $4.70 $61.70 $ 0.00 $1.80 $0.00 $1.19 $0.84 $10.98 $0.56 $7.31 $0.79 $10.35 $38.87 $510.02 ====EEEEE Total $603.35 //Save the following program as Supermarket.java //Create the Supermarket class //Create the main method //Declare and assign variables for //count of items, item name, taxable, item price, cost, discount, tax, total, and //grand total //Use printf to print the header line used in the spreadsheet for this problem /* See Hints section - Using the same data used in the Lab l's spreadsheet: Set the count variable, the item variable, "T" or "NT" for the taxable variable and the item price variable. With these set, calculate the cost, discount, tax and total amounts. Be sure to Increment the grand total with the total amount. */ //Use printf to output the row of data with good alignment (See hints section) 1/Repeat the process 7 times as was done in the spreadsheet //As the last output row, output the grand total amount //End main method //End class Hints: //Determine and calculate discount example double discounti 0; if (counti 6) { discounti costi lt_6_discount; } else if(count1 11) { discounti costi * lt_11_discount; } else { discounti costi * discount; //Determine and calculate taxes example double tax1 = 0.0; if(taxablel.equalsIgnoreCase("T")) { tax1 (costi discountl) * tax; //Display output using printf example; Note: width in the format specifiers may need to be //adjusted slightly for the other rows System.out.printf("%d%15s%13s%12s%.2f%115%.2f%65%.2f%11s%.2f%55%.2f ", count1, "Pants", taxable1, "$", price1, "$", cost1, "$", discount1, "$", taxi, "$", totall); The output should look like this: Tax Total Count Item Taxable Price/Item Cost Discount =========== 4 Pants T $15.00 $60.00 $3.00 10 Apples NT $0.20 $2.00 $0.20 5 Pears NT $0.25 $1.25 $0.06 4 Quarts of Oil T $2.67 $10.68 $0.53 6 6 Dishes T $1.25 $7.50 $0.75 15 Silverware T $0.75 $11.25 $1.69 1 Laptop T $495.95 $495.95 $24.80 =============================================================================== $4.70 $61.70 $ 0.00 $1.80 $0.00 $1.19 $0.84 $10.98 $0.56 $7.31 $0.79 $10.35 $38.87 $510.02 ====EEEEE Total $603.35
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