Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number
Question:
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. Create a UsedCar class with fields for 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 1990 and 2014 inclusive; or either the mileage or price is negative. Save the class as UsedCar.java. Write an application that establishes an array of at least seven UsedCar objects and handles any Exceptions. Display a list of only the UsedCar objects that were constructed successfully. Save the file as ThrowUsedCarExceptions.java.
Step by Step Answer:
ThrowUsedCarException public class ThrowUsedCarException public static void mainString args UsedCar cars new UsedCar7 String vins 1234 2345 234Q 12345 ...View the full answer
Students also viewed these Computer science questions
-
List six ways that simulation can be used in business?
-
List the ways an information system can be used in a career area of interest to you.
-
The Wittig reaction (Section 16.10) can be used in the synthesis of aldehydes, for example, (a) How would you prepare CH3OCH == P(C6H5)3? (b) Show with a mechanism how the second reaction produces an...
-
An analysis of spending by a sample of credit card bank cardholders shows that spending by cardholders in January (Jan) is related to their spending in December ( Dec): The assumptions and conditions...
-
Replacement times for TV sets are normally distributed with a mean of 8.2 years and a standard deviation of 1.1 years (based on data from "Getting Things Fixed," Consumer Reports). Find the...
-
Explicar los propsitos de cada paso en el proceso de un producto nuevo .
-
E12.2. Analyzing a Change in Return on Common Equity (Easy) The following numbers were calculated from the financial statements for a firm for 2009 and 2008: 2009 2006 Return on common equity (ROCE)...
-
Presented below are two independent situations. 1. Speedy Car Rental leased a car to Mayfield Company for one year. Terms of the operating lease agreement call for monthly payments of $500. 2. On...
-
1. Selected information concerning sales and production for Abigail Co. for September are summarized as follows: Estimated sales: Product KitKat: 80,000 units at $60 per unit Product Lynx: 40,000...
-
Convert the following sentences into predicate calculus: i Ram was ruler of Ayodhya 11 Ravana was ruler of Lanka i1 Ravana was enemy of Ram iv Ravana abducted Sita V Sita was wife of Ram vi Ram...
-
Create an ApartmentException class whose constructor receives a String that holds a street address, an apartment number, a number of bedrooms, and a rent value for an apartment. Save the file as...
-
Create an application that accepts employee data interactively. Users might make any of the following errors as they enter data: The employee number is not numeric, less than 1000, or more than 9999....
-
What are some common ways to remove cores from castings? To remove runners, gates, and risers?
-
Think back to a time you experienced a communication breakdown in a personal or social setting (something you're comfortable discussing with the class in a public forum). 1. Did you figure out why...
-
Imagine you are visiting your aunt, who is a patient in a hospital in a nearby city. While you are sitting at her bedside, you hear a lot of noise at the nurses' station, as if they are having a...
-
Using Houseplan #5 on page 4 of the Measurement supplement(below), determine the cost of pouring the 9 inch thick concreteslab for this home, assuming that the porch will also be on thefoundation....
-
Recall from lecture that Flip-Flap Railway is an old roller coaster that was built in a circle. It has a diameter of 25 ft and riders entered the ride at a speed of 45 mph. At the top of the loop,...
-
Small Fry Design, founded in 1997, is a toy and accessories company that designs and imports products for children. The company's line of merchandise includes teddy bears, musical toys, rattles and...
-
On December 2, 2023, Joan borrowed $2400, agreeing to repay the loan with blended payments of $292 per month, starting on January 2. Interest was charged at 7.8% per annum calculated on the monthly...
-
Explain the buyers position in a typical negotiation for a business. Explain the sellers position. What tips would you offer a buyer about to begin negotiating the purchase of a business?
-
A constructor _____________ overloaded. a. Must be b. Cannot be c. Can be d. Is always automatically
-
Usually, you want each instantiation of a class to have its own copy of _____________. a. The data fields b. The class methods c. Both of the above d. None of the above
-
If you create a class that contains one method, and instantiate two objects, you usually store _____________ for use with the objects. a. One copy of the method b. Two copies of the method c. Two...
-
Comfort Golf Products is considering whether to upgrade its equipment Managers are considering two options. Equipment manufactured by Stenback Inc. costs $1,000,000 and will last five years and have...
-
Weaver Corporation had the following stock issued and outstanding at January 1, Year 1: 71,000 shares of $10 par common stock. 8,500 shares of $60 par, 6 percent, noncumulative preferred stock. On...
-
Read the following case and then answer questions On 1 January 2016 a company purchased a machine at a cost of $3,000. Its useful life is estimated to be 10 years and then it has a residual value of...
Study smarter with the SolutionInn App