Question: Need help with Java program CPS 2231-04/ Spring 2017 Homework #2, Name: Please complete the problems below. Attach source code or a hand-written answer as
CPS 2231-04/ Spring 2017 Homework #2, Name: Please complete the problems below. Attach source code or a hand-written answer as requested in the question. Due date: 4/26 at end of class (please hand in source code where requested) Total points: 40 points 1. (5 points Classes and objects) Hand-write a complete Java class that can be used to create a Product object as described below. a. A product has a: i. Product name ii. Product cost iii. Amount of product in stock (as a whole number) b. Add all instance variables c. The class must have getters and setters for all instance variables d. The class must have two constructors, a no-args and a constructor that receives input parameters for each instance variable. e. Add a method which changes the price of the product by a given percent: public void markdown(double byPercent) The markdown method is used to change the price of the product prior to putting t on sale. For example: Below is code that creates a product, Towel", with an original price of $12.00 and 30 units in stock. The price will change to $6.00 when the markDown method is called passing .5 as a parameter Product p a new Product Towel", 12.00, 30); name, price and quantity in stock p mark Down(.5); 2. (5 points creating objects Write the statements (which would be in a client program, TestProduct) to create two Product objects with the information below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
