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...
-
Rolling Hills Golf Inc. was organized on July 1, 2012. Quarterly financial statements are prepared. The trial balance and adjusted trial balance on September 30 are shown here. Instructions(a)...
-
4. Conley owned video poker machines. They are outlawed in Pennsylvania, but he placed them in bars and clubs. He used profits from the machines to buy more machines. Is he guilty of money laundering?
-
Timmons Corporation is considering three long-term capital investment proposals. Relevant data on each project are as follows. Salvage value is expected to be zero at the end of each project....
-
(Q5) Bill plans to open a self-serve grooming center in a storefront. The grooming equipment will cost $400,000, to be paid immediately. Bill expects aftertax cash inflows of $80,000 annually for six...
-
1. An experiment consists of tossing a coin two times and observing the sequence of heads and tails. (a) What is the sample space of this experiment? (b) Describe the event "the first toss is a head"...
-
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....
-
Researchers have found that psychological distance from our current situation facilitates selfcontrol and allows individuals to transcend urgencies of a situation by taking a more distanced...
-
Which of the data visualization tools in Example Tools and Vendors would be suited for use in an enterprise level organization and which would be suited for use in a small to medium-sized business?
-
Why might there be resistance to establishing common international accounting standards?
-
Which of the data visualization tools in Example Tools and Vendors are open source tools?
-
In addition to financial information, what other information do you think is important in order to evaluate the achievement of a public sector entity?
-
Assume that Boardmaster paid expenses totaling $38,000. How does this transaction affect Boardmasters accounting equation? a. Increases assets and decreases liabilities b. Increases both assets and...
-
Explain how you would class each of the following - as a sole trader, partnership or limited company. List any further questions you might ask for clarification about the nature of the business. (a)...
-
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...
-
Find the derivative. r = 14-08 cos 0 (dr/de) = 807 sin e (dr/de) = : 807 sin 0 - 08 cos e (dr/de) = : 807 cos 0 - 08 sin e (dr/de) == - 807 cos 0 + 08 sin e Question 22 Find dy/dx by implicit...
-
QUESTION 4 Find the indicated probability. A sample of 4 different calculators is randomly selected from a group containing 36 that are defective and 27 that have no defects. What is the probability...
-
A holacracy is a style of governance based on A) profit margins, which involves employees being promoted based on their contribution to a company's profitability. B) individual autonomy, which...
Study smarter with the SolutionInn App