Ask 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: 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

+4
Answers (1)
  1. 25 May, 04:28
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers