Ask Question
24 March, 21:26

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

+5
Answers (1)
  1. 25 March, 00:12
    0
    public class Main

    {

    public static void main (String[] args) {

    RetailItem ob1 = new RetailItem ("Jacket", 12, 59.95);

    RetailItem ob2 = new RetailItem ("Designer Jeans", 40, 34.95);

    RetailItem ob3 = new RetailItem ("Shirt", 20, 24.95);

    }

    }

    class RetailItem {

    private String itemDescription;

    private int units;

    private double price;

    public RetailItem (String itemDescription, int units, double price) {

    this. itemDescription = itemDescription;

    this. units = units;

    this. price = price;

    }

    }

    Explanation:

    Create a class called RetailItem that has three variables itemDescription, units, and price

    Initialize a constructor that takes three parameters to set the values

    Inside the main, create three objects with given data
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers