Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I\'ve been stuck on this one for a while and I\'d really appreciate some help

ID: 3569296 • Letter: S

Question

So I've been stuck on this one for a while and I'd really appreciate some help.

The question is from Starting Out With Java Early Objects:

Write a CashRegister class that can be used with the RetailItem class that you modified Programming Challenge 7 (I have that written and will attach it at the bottom). The CashRegister class should simulate the sale of a retail item. it should have a constructor that accepts a RetailItem object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. In addition, the class should have the following methods:

- The getSubtotal method should return the subtotal of the sale, which is the quantity multiplied by the retail cost. This method must get the retail cost from the Retailitem object that was passed as an argument to the constructor.

- The getTax method should return the amount of slaes tax on the purchase. The sales tax rate is 6% of the retail sale.

- The getTotal method should return the total of the sale, which is the subtotal plus the sales tax.

Heres the RetailItem I wrote:

Any help would be appreciated.

Explanation / Answer

/**

This is a reatailItemdemo

*/

public class DTRetailItemdemo

{

public static void main(String[] args)


{

DecimalFormat formatter = new DecimalFormat("$#,##0.00");


// Jackets.

RetailItem item1 = new RetailItem();

item1.setDescription("Jacket");

item1.setUnitsOnHand(12);

item1.setPrice(59.95);

// designerJeans.
RetailItem item2 =new RetailItem();

item2.setDescription("designerJeans");

item2.setUnitsOnHand(40);

item2 setPrice(34.95);

// Shirts.

RetailItem item3 = new RetailItem();

item3.setDescription("Shirt");

item3.setUnitsOnHand(20);

item3.setPrice(24.95);

// Display the info for Jacket.

System.out.println("Jacket");

System.out.println("Description: " + item1.getDescription());

System.out.println("Units on hand: " + item1.getUnitsOnHand());

System.out.println("Price: " + item1.getPrice());

// Display the info for designerJeans.

System.out.println(" designerJeans");

System.out.println("Description: " + item2.getDescription());

System.out.println("Units on hand: " + item2.getUnitsOnHand());

System.out.println("Price: " + item2.getPrice());

// Display the info for Shirts.

System.out.println(" Shirts");

System.out.println("Description: " + item3.getDescription());

System.out.println("Units on hand: " + item3.getUnitsOnHand());

System.out.println("Price: " + item3.getPrice());

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote