Question: 1 . - Create a class Product which will have the following attributes: name, expiration date and price. - For the expiration date, you can

1.
- Create a class Product which will have the following attributes: name, expiration date and price.
- For the expiration date, you can use the Date class posted on Teams.
- Make sure to implement a mechanism which will check whether the price is equal to zero or below it.
- If the price is below zero, it should throw an Exception called InvalidPriceException.
- The aforementioned Exception should be created by you (it should have two constructors).
- Finally, create a ProductDemo class in which you will test out both situations using the try-catch block, when the price is larger than zero and equal or below it (when the Exception should be thrown).
- Include the screenshot of both situations, or one screenshot which will show both situations in the console.
1 . - Create a class Product which will have the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!