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...
-
Are the validity conditions met so we can perform follow-up analysis (pairwise comparisons) using theory-based techniques? Explain.
-
The data below shows birth rate and per capita income (in thousands of 2011 dollars) from 2000 through 2012. Draw a time-series plot for both birth rate and per capita income. Comment on any...
-
A pawnshop will lend $2,500 for 45 days at a cost of $35 interest. What is the effective rate of interest?
-
Mickley Company's plantwide predetermined overhead rate is $23.00 per direct labor-hour and its direct labor wage rate is $14.00 per hour. The following information pertains to Job A-500: Direct...
-
If a mothers self-report is considered completely accurate, then what is the PV+ of the daughters report, in which positive indicates smoking and negative indicates not smoking? Obstetrics, Health...
-
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....
-
Compute the amount of interest on $835 at 7.5% p.a. from October 8, 2015, to August 4, 2016.
-
On 2 October 2002, the Securities and Exchange Commission (SEC) filed a civil enforcement action against Andrew S. Fastow, the former Chief Financial Officer of Enron Corp., for alleged fraud. The...
-
The To Complete Performance Index (TCPI) is a measure of the cost performance required in order to finish the outstanding work within the remaining budget. The formula for this index is...
-
The following is a production function. a. Draw a graph of marginal product as a function of output. b. Does this graph exhibit diminishing returns? Explain your answer.
-
Your manager has obtained the following information on comparable stocks A and B, both of which are estimated to have a discount rate of 15 per cent. Calculate the dividend payout ratios for each...
-
Following is a list of all the named hurricanes in the Atlantic between 2001 and 2010, along with their category on the Saffir-Simpson Hurricane Scale, which categorizes each hurricane by a label...
-
Let c1, c2 ,...... cn, en be positive constants with And let x1, x2, ..........., xn be positive numbers. Take natural logarithms and then use l'Hopital's Rule to show that 12 1/r 12 lim (axby)yb
-
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...
-
Could you meet these guidelines? White paper outline identifies a problem worth solving, states why it's important and gives at least two recent cases illustrating one successful strategy for solving...
-
If you have a professional relationship in some manner with a pregnant woman that is in an abusive situation, such as her counselor or medical professional, how would you address her returning to an...
-
There is no correct or incorrect answer for who you decide to hire and who you decide to reject, however you must explain the reason for your decision. In addition to writing the rejection letter,...
Study smarter with the SolutionInn App