Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program that do the following: Create a class named Software that consists of the following: - Three instance data members of private

image text in transcribed
image text in transcribed
Write a java program that do the following: Create a class named Software that consists of the following: - Three instance data members of private access modifier: softwareld: represents the id of the Software and its datatype is integer. softwareType: represents the type of the Software and its data type is string. softwarePrice: represents the price of the software and its datatype is double. - One static data member of public access modifier: softwareCn: keeps track of the number of Software's objects that are created from the Software class, Its type is integer. - Member methods as follows: 1. Default constructor to initialize the softwareld to zero, softwareType to empty string, and the softwarePrice to zero. 2. Parameterized constructor that receives values for the following data members (softwareld, softwareType, and softwarePrice), then it sets the received values in the class data members. 3. Create a method named setSoftwarePrice that sets a value in the softwarePrice data member. Be sure that the value is nonnezative. 4. Create a method named getSoftwareld that returns the value of the softwareld. 5. Create a method named isCheap that returns true if the price of the Software is less than or equals to $20, and returns false otherwise. 6. Create a method named copiesSoftlicPrice that receives the number of copies (called numcopier as a method parameter) the user want to buy and retums the total price that the user should pay. However, the user will get 20% discount if he buy 2 copies, 40% discount if he buy 3 copies. and 50% discount if he more than 3 copies. [Hint: total price - softwarePrice " numCopies * (1 - discount ) ] 7. Create a method named showsoftDetails that prints the values of the data members in the following form at: Example 1 If thevalue in the created object is (id =111, type=-proetarmeg Scetwaren, proce =150 ) And user want buy 2 coples Qupat The Sotware id is 111 and its type is Proeraming Sottware The Software copies total cot $24. Howover, it is a cheap Softrare B. Write a Demo class that contains the main method. In the main method do the following: 1. Create an object of the Software class named sfi using the default constructor. 2. Create another object of the Software class named sf 2 using the parameterized constructor. Ask the user to input the softwareld, softwareType, and softwarePrice. 3. Call the method setSoftwarePrice for the sfi object to set the price of that object to be 15.0 4. Print the value of the softwareC n static data member. 5. Call the copiessoftlicPrice(2) then call the showsoftDetails method using the object sf1. 6. Call the copiesSoftlicPrice(5) then call the showSoftDetails method using the object sf2

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Write a short notes on Iso-q uant.

Answered: 1 week ago