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

Python Programming Python 3 RetailItem Class Write a class named RetailItem that

ID: 640408 • Letter: P

Question

Python Programming Python 3

RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description, units in inventory, and price.

Once you have written the class, write a program that creates three RetailItem objects and stores the following data in them:

Description                         Units in Inventory                            Price

Item #1        Jacket                                   12                                          59.95

Item #2        Designer Jeans                  40                                              34.95

Item #3      Shirt                                       20                                         24.95

Add a method to the RetailItem class that returns the inventory value of item

Explanation / Answer

import java.text.DecimalFormat; //needed to format the Output

/**

This is a reatailItemdemo

*/

public class DTRetailItemdemo
{
public static void main(String[] args)

{

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


// Jackets.
   DTRetailItem item1 = new DTRetailItem();
item1.setDescription("Jacket");
item1.setUnitsOnHand(12);
item1.setRetailPrice(59.95);

// designerJeans.
   DTRetailItem item2 =new DTRetailItem();
       item2.setDescription("designerJeans");
       item2.setUnitsOnHand(40);
       item2.setRetailPrice(34.95);

// Shirts.
   DTRetailItem item3 = new DTRetailItem();
item3.setDescription("Shirt");
item3.setUnitsOnHand(20);
item3.setRetailPrice(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.getRetailPrice());

// 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.getRetailPrice());

// 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.getRetailPrice());
}
}

second code-->>

/**
    The following program will "show the user what inventory is in stock, units on hand, and price".
*/

public class DTRetailItem
{
public static void main(String[] args)
{
}

   //fields
   private String description;       // description of item
   private int unitsOnHand;       // number of items
   private double retailPrice;       // price of item

   /**
   set methods to appropriate name
   */

   public void setDescription(String des)

   {
       description = des;

   }

   public void setUnitsOnHand(int unit)

   {
       unitsOnHand = unit;

   }

   public void setRetailPrice(double price)

   {
       retailPrice = price;

   }

   /**
   get method and return value of each variable
   */


   public String getDescription()

   {
       return description;

   }

   public int getUnitsOnHand()

   {
       return unitsOnHand;

   }

   public double getRetailPrice()

   {

       return retailPrice;

   }
}