Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. Define the attributions we use to explain behavior

Answered: 1 week ago