Question
Program 1. Vehicle Registration Program using netbeans .java This program will be used to calculate vehicle registration fees. It will include a Vehicle parent class,
Program 1. Vehicle Registration Program using netbeans .java This program will be used to calculate vehicle registration fees. It will include a Vehicle parent class, a Car subclass, and a Calculate interface that is implemented by the Car class. The steps are outlined below. 1. Write an interface called Calculate that includes one method - calcFee - that will calculate the registration fee for a vehicle. calcFee returns a float and doesn't take any parameters. 2. Create a class called Vehicle. This class contains the following attributes:
owner (String) regNumber (int)
The Vehicle class contains methods to set/get owner and regNumber. Its constructor should initialize all variables to 0 or "" (depending on type). Vehicle will have subclasses. 3. Create a subclass of Vehicle called Car that implements the Calculate interface. Car should have additional attributes of:
make (String) model (String) regType (String - values will be either "new" or "renew") regFee (float)
In addition to the get/set methods for make, model, and regType, include the method calcFee, to calculate the registration fee according to the following conditions:
if regType = renew, then the fee is $36 else if regType = new, then the fee is $58.50
NOTE: To compare two strings in Java, use the "equals" method rather than ==; e.g., if (string1.equals(string2)) When getting input from the user using sc.nextInt() (this assumes that you named your Scanner object "sc"), there will be a newline left in the buffer. Simply put the statement sc.nextLine() after your sc.nextInt() statement to clear the newline from the buffer. 4. In your main class for the program, create a car object called myCar (be sure and include make, model, and registration type [either new or renew] in the constructor call statement). Get the following input from the user:
owner name registration number make model registration type
Calculate the registration fee, then display the owner name, registration number, registration type, and registration fee. NOTE: The following statement will print the result of the calcFee() method with two decimal places (and go to a new line):
System.out.format("Amount: $ %.2f%n", myCar.calcFee());
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started