2.99 See Answer

Question: Create a UsedCarException class that extends


Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor so it can be used in a getMessage() call. Save the class as UsedCarException.java.
b. Create a UsedCar class with fields for a VIN, make, year, mileage, and price. The UsedCar constructor throws a UsedCarException when the VIN is not four digits; when the make is not Ford, Honda, Toyota, Chrysler, or Other; when the year is not between 1997 and 2024 inclusive; or either the mileage or price is negative. Save the class as UsedCar.java.
c. Write an application that establishes an array of at least seven UsedCar objects and prompts the user for values. Include two catch blocks. One catches any data entry Exceptions and displays a message. The other catches UsedCarExceptions that are thrown from the UsedCar constructor. When data entry is complete, display a list of only the UsedCar objects that were constructed successfully. Save the file as ThrowUsedCarException.java

2.99

See Answer