Question: //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,


//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
Get step-by-step solutions from verified subject matter experts
