![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 22.09.2020 16:01 aparedes5
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. 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 1997 and 2017 inclusive; or either the mileage or price is negative. 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.
1.
public class ThrowUsedCarException {
public static void main(String[] args) {
// Write your code here
}
}
2.
import java. util.*;
public class UsedCar {
String vin;
String make;
int year;
int mileage;
int price;
public final static String DEFAULT_VIN = "999";
final int VIN_NUM_LENGTH = 4;
final int LOW_YEAR = 1997;
final int HIGH_YEAR = 2017;
final String[] MAKES = {"Ford", "Honda", "Toyota", "Chrysler", "Other"};
public UsedCar(String num, String carMake,
int carYear, int miles, int pr) throws UsedCarException {
}
public UsedCar() {
}
public String getVin() {
}
public String toString() {
return "VIN " + vin + " Make: " + make +
"\n Year: " + year + " " + mileage + " miles $" +
price;
}
}
3.
public class UsedCarException extends Exception {
public UsedCarException(String s) {
}
}
![ansver](/tpl/images/cats/User.png)
Answers: 2
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 03:30
Many everyday occurrences can be represented as a binary bit. for example, a door is open or closed, the stove is on or off, and the fog is asleep or awake. could relationships be represented as a binary value? give example.
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 19:30
You can apply several different worksheet themes from which tab?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
You know the right answer?
Create a UsedCarException class that extends Exception; its constructor receives a value for a vehic...
Questions
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 20.09.2020 16:01
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 20.09.2020 16:01
![question](/tpl/images/cats/mat.png)
Mathematics, 20.09.2020 16:01
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 20.09.2020 16:01
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 20.09.2020 16:01
![question](/tpl/images/cats/mat.png)
Mathematics, 20.09.2020 16:01
![question](/tpl/images/cats/ap.png)
Advanced Placement (AP), 20.09.2020 16:01
![question](/tpl/images/cats/mat.png)
Mathematics, 20.09.2020 16:01
![question](/tpl/images/cats/User.png)
Engineering, 20.09.2020 16:01
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/ekonomika.png)
![question](/tpl/images/cats/ekonomika.png)