Question: 2. Write a class called Item. Each item has a number (integer), a name (string), and a price (double). The class should have only one
2. Write a class called Item. Each item has a number (integer), a name (string), and a price (double). The class should have only one constructor with 2 parameters only. The constructor initializes the item name and number according to the parameters' values, and initializes price to some random double value that is between 0 and 100. The class should also have a void method called show to print the information (number, name, and price) of an Item object; a method called discount that takes a discount amount as a parameter (percentage of discount is 10, 20 or 50%) and then returns the price after applying the discount without changing the price value of the object. Don't include any setters or getters. Add a main function to create different items and display them
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
