Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
A. 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 data type is integer. softwareType: represents the type of the Software and its data type is string- softwarePrice: represents the price of the software and its data type 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 nonnegative. 4. Create a method named getSoftwareld that returns the value of the softwareid. 5. Create a method named is Cheap 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 numcopies as a method parameter) the user want to buy and returns 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,l 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 format: Example 1: if the yalues in the created object is (id =111, type - "Programming Sottware", price =15.0 ) And user want buy 2 copies. Quput: The Software id is 111 and its type is Programming software. The Software copies total goss $24. However, it is acheap Software. Example 2: If the yalues in the created object is (id =333, type " "Medical Software", price 30.0 ) And user want buy 5 copies. Qupit: The Software id is 333 and its type is Medical Software. The Software copies total cost 575 However, it is an expensive Software. [Hint: you may use the is Cheap function to detect if the Software is cheap or expensive]

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

Recommended Textbook for

More Books

Students also viewed these Databases questions