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...
-
On January 2, 2019, P Company, a U.S.-based company, acquired for 2,000,000 francs an 80% interest in SFr Company. On January 2, 2019, SFr Company reported a retained earnings balance of 480,000...
-
A woman is riding a bicycle down an \(18 \%\) slope. Her velocity is \(25 \mathrm{~km} / \mathrm{hr}\) into an oncoming \(25-\mathrm{km} / \mathrm{hr}\) wind. The air is at \(15{ }^{\circ}...
-
Consider the following parlor game to be played between two players. Each player begins with three chips: one red, one white, and one blue. Each chip can be used only once. To begin, each player...
-
Cost of a Fixed Asset Borges Inc. recently purchased land to use for the construction of its new manufacturing facility and incurred the following costs: purchase price, $83,000; interest charges,...
-
Jimmy owns a garden in which he has planted N trees in a row. After a few years, the trees have grown up and now they have different heights. Jimmy pays much attention to the aesthetics of his...
-
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....
-
Motif Furniture is an Austin-based furniture company. For each of the following first-quarter transactions, indicate whether operating (O), investing (I), or financing activities (F) are affected and...
-
Chess and poker are games requiring coordination. Discuss some of lifes games and how they require coordination. Be creative and give specific examples.
-
UGT assumes that media present content and consumers choose when and how to consume it. How does the Internet threaten to disrupt this model? How might UGT adapt to allow for the transformation of...
-
Some critics have charged that SPT focuses too much on self-disclosure. Others, however, contend that self-disclosure forms the basis of most intimate relationships. What do you think? Is there a...
-
If you outlined the stages of a past romantic relationship of yours, would it follow the sequencing that Altman and Taylor suggest? What similarities are there to the social penetration process? What...
-
Carol Fahey feels embarrassed about offering her opinions to a group that does not share her beliefs. Consider a similar time in your life. Did you speak out, or did you decide to remain quiet? What...
-
Two or more items are omitted in each of the following tabulations of income statement data. Fill in the amounts that are missing. 2015 $290,000 6,000 2016 2017 $410,000 Sales Sales returns Net sales...
-
Define relevant costs and discuss: (1) whether all future costs are relevant for decision making and (2) whether variable costs are always relevant and fixed costs are always irrelevant
-
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...
-
Estimate the final temperature in Celsius of the combination if I drop 5 rolls of pennies at 2 0 C ( each roll is 5 0 pennies stacked together; assume they are pure copper ) into a cup of recently -...
-
A 100 gram mass is hung of then end of a cantilever beam . The beam is made of brass, and is 30 cm long (), 2 cm wide, and 3 mm thick. Find the resulting deflection ()
-
The nitrogen-vacancy (NV) and silicon-vacancy (SiV) defects in diamond can lead to many exciting quantum nanotechnologies in physical and biological sciences, including single-photon sensors,...
Study smarter with the SolutionInn App