subject

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
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
You have been supporting csm tech publishing's windows server 2016 server network for over a year. the office has two windows server 2016 servers running active directory and a number of other roles. management has informed you that a small sales office is opening in the same building three floors up. the sales manager wants to install a sales application on a server located in the sales office. this server will have limited physical security because there's no special room dedicated for it, which means it will be accessible to non-it personnel and visitors. you're considering installing windows server 2016 server core on the new server because accessing its console regularly probably won't be necessary, and this server will be managed from one of the other csm tech publishing servers. what are the benefits and drawbacks of using server core for this branch office? what are some things you should do to set up this server management environment?
Answers: 1
question
Computers and Technology, 24.06.2019 08:20
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
question
Computers and Technology, 24.06.2019 17:40
Pseudocode pld #6, pg. 117 start// declarations// number numbertoguess// number myguess; numbertoguess = 92// while myguess ! = numbertoguess// output " guess an integer number between 1 and 100"// input myguess// if (myguess == numbertoguess)// output "you guessed the correct number"// else// output "the number you guessed was incorrect. try again! "// end if// end while// output " for playing the guessing game. have a great day! "// stop
Answers: 3
question
Computers and Technology, 25.06.2019 06:30
During which stage do you think is the best time for a company to purchase an emerging technology
Answers: 1
You know the right answer?
Create a UsedCarException class that extends Exception; its constructor receives a value for a vehic...
Questions
question
French, 22.04.2020 22:04
question
History, 22.04.2020 22:04
question
Mathematics, 22.04.2020 22:04