View the step-by-step solution to:


Java, help with program

A class named RetaiI_Item that holds data about an item in a retail store. The class

should store the following data in attributes:

  •  Item Number
  •  Item Description
  •  Units in Inventory
  •  Price

  • Make Another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should have the following methods:
  •  A method named display_menu that displays the snapshot of data in the store.
  •  A method named purchase_item that accepts a Retail_Item object as an argument. Each time the purchase_item method is called, the Retail_Item that is
  • passed as an argument should be added to the list.
  •  A method named get_total that returns the total price of all the Retail_Items
  • objects stored in the Cash_Register's internal list.
  •  A method named show_items that displays data about the Retail_Item objects
  • stored in the Cash_Register object's internal list.
  •  A method named clear that should clear the Cash_Register object's internal list.
  • Make A TestBonus class that uses ArrayList to store Retail_Item objects. Each object in the ArrayList should hold data about an item in the retail store (Item Number, Item Description, Units in Inventory, and Price). The test class should also use the Cash_Register objects to allow the user to select several items for purchase, using a menu. See the program menu on the second page. These objects must be stored in an ArrayList. When the user is ready to check out, the program should display a list of all the items he or she has selected for purchase, as well as the total price, taxes (8.25%), and the final price. The data for the retail store is available in the file Bonus.txt. (Note: This program might be tested with a different file so allow the user to enter the name of the file.)
  • Allow the user to run the program as many times as possible until a sentinel value, less than zero (0), has been entered for the selected item. No input, processing, or output should happen in the main method. All work should be delegated to other non-static methods.

Program Menu

1. Pants

2. Jeans

3. Shirt

4. Dress

5. Socks

6. Sweater

7. Jacket

8. Suit

9. Swimsuit

10. Skirt

11. Clear Cash Register

12. Show Inventory

13. Check Out


1000 Pants 10 19.99

2000 Jeans 2 25.95

3000 Shirt 15 12.50

4000 Dress 3 79.00

5000 Socks 50 1.98

6000 Sweater 5 49.99

7000 Jacket 1 85.95

8000 Suit 2 150.98

9000 Swimsuit 6 44.50

9500 Skirt 4 65.99  

*** What i have so far

public class Retail_Item {

int itemNum;

String itemDesc;

int unitInv;

double price;


public void setINum( int ItemNum){

itemNum = ItemNum;


public void setIDesc( String ItemDesc){

itemDesc = ItemDesc;


public void setUInv( int UnitInv){

unitInv = UnitInv;


public void setIPrice( double Price){

price = Price;


public int getINum(){

return itemNum;


public String getIDesc(){

return itemDesc;


public int getUInv(){

return unitInv;


public double getIPrice(){

return price;



public Retail_Item(int numOfItems, String itemDescription, int inventoryUnit, double itemPrice){

itemNum = numOfItems;

itemDesc = itemDescription;

unitInv = inventoryUnit;

price = itemPrice;



import java.util.ArrayList;

import static java.util.Collections.list;

import java.util.List;



public class Cash_Register{

//Create list of Retail Item

private List<Retail_Item> list = new ArrayList<>();


public void display_menu(){

System.out.print("1. Pants%n2. Jeans%n3. Shirt%n4. Dress%n5. Socks%n6. "

+ "Sweater%n7. Jacket%n8. Suit%n9. Swimsuit%n10. Skirt%n "

+ "11. Clear Cash Register%n12. Show Inventory%n13. Check Out");



public void purchase_item(Retail_Item r){

//Adds RetailItem class object to list




public double get_total(){

double total = 0;

for (int i = 0; i < list.size(); i++){

total +=list.get(i).getIPrice();


return total;


public void show_items(){

System.out.printf("The items in the cash register are:%n%n");

for (Retail_Item item : list){

System.out.printf("Item %2d: ", item);



public void clear(){


Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes