Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year,
Question:
Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, and miles per gallon. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. Do not allow the year to be earlier than 2000 or later than 2017; if it is, set the year to 0. Do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0. Include a constructor that accepts arguments for each field value and uses the set methods to assign the values. Write an application that declares several Automobile objects and demonstrates that all the methods work correctly. Save the files as Automobile.java and TestAutomobiles.java.
Step by Step Answer:
Automobile public class Automobile private int id private String make private String model private String color private int year private double mpg pu...View the full answer
Students also viewed these Computer science questions
-
The table gives the number of miles per gallon in the city and on the highway for the coupes and compact cars reported to have the best gasoline mileage, according to autobytel.com. Make a...
-
The number of miles traveled per gallon of gasoline for a certain car has a mean of 25 and a standard deviation of 2. The tank holds 20 gallons. a. Find the mean number of miles traveled per tank. b....
-
The following data represent the number of miles per gallon achieved on the highway for small cars for the model year 2011. (a) Construct a stem-and-leaf plot and (b) Describe the shape of the...
-
Magna Jets is a medium sized company that manufactures luxury goods for several well-known chain stores. In real terms, the company has experienced only a small growth in turnover in recent years,...
-
Air Borealis works only with advance reservations and experiences a 7% rate of no-shows. How many reservations could be accepted for an airliner with a capacity of 250 if there is at least a 0.95...
-
The authors of the paper ?Risk of Malnutrition Is an Independent Predictor of Mortality, Length of Hospital Stay, and Hospitalization Costs in Stroke Patients? (Journal of Stroke and Cerebrovascular...
-
The structure shown in Fig. P9.71 consists of three cylindrical support posts to which an elliptical flat plate sign is attached. Estimate the drag on the structure when a \(50-\mathrm{mph}\) wind...
-
Georgia Company reported accounts receivable of $16.5 million at the end of its 2004 fiscal year. This amount was net of an allowance for doubtful accounts of $1,800,000. During 2005, Georgia sold...
-
What would be the value of x after the following statements were executed? int x; for (x=0; x
-
The position of a particle as a function of time is given by r(vector) = (5.0i + 4.0j)t 2 m, where t is in seconds. a. What is the particles distance from the origin at t = 0, 2, and 5 s? b. Find an...
-
What is the output of the following code segment? t = 10; if(t > 7) { System.out.print("AAA"); System.out.print("BBB"); } a. AAA b. BBB c. AAABBB d. Nothing
-
What is the output of the following code segment? t = 0; if(t > 7) System.out.print("AAA"); System.out.print("BBB"); a. AAA b. BBB c. AAABBB d. Nothing
-
Your firm is issuing $98 million in straight bonds at par with a coupon rate of 5.5% and paying total fees of 2.9%. What is the net amount of funds that the debt issue will provide for your firm?
-
A labeled point has x- and y-coordinates and a string label. Provide a class Labeled- Point with a constructor LabeledPoint(int x, int y, String label) and hashCode and equals methods. Two labeled...
-
Modify Exercise P16.14 so that you mark removed elements with an inactive element. You cant use nullthat is already used for empty elements. Instead, declare a static variable: Data from exercise...
-
A deque (double-ended queue) is a data structure with operations addFirst, remove- First, addLast, removeLast, and size. Implement a deque as a circular array, so that these operations have amortized...
-
Describe the need for objectives and the characteristics of suitable objectives.
-
Explain what the following code prints. Draw a picture of the linked list after each step. LinkedList staff = new Linked List (); staff.addFirst("Harry"); staff.addLast ("Diana");...
-
Lots Lumber Limited is a private company that operates in the forestry sector and owns timber lots. The company produces specialty lumber and sells to distributors and retailers. Currently, Lots uses...
-
How has the globalization of firms affected the diversity of their employees? Why has increased diversity put an additional burden on accounting systems?
-
An escape sequence always begins with a(n) _____________. a. e b. Forward slash c. Backslash d. Equal sign
-
Which Java statement produces w on one line and xyz on the next line? a. System.out.println(wxyz); b. System.out.println(w + xyz); c. System.out.println(w xyz); d. System.out.println(w x y z);
-
The remainder operator _____________. a. Is represented by a forward slash b. Must follow a division operation c. Provides the quotient of integer division d. Is none of the above
-
What are the vulnerabilities of embedded operating systems, such as, but not limited to, IoT devices, programmable logic devices, and vehicle control systems.
-
Factor the polynomial completely. 7x-17x-12
-
What are some relevant recommendations about Coca-Cola's Planning, Design, and Implementation of an Enterprise Resource Planning System that other companies can apply to their own initiatives?
Study smarter with the SolutionInn App