Java Program Write an abstract Java class named Vehicle. It has two attributes grade(private) and roadTax(public) with types respectively String and double types. The constructor of Vehicle class...


Java Program


Write an abstract Java class named Vehicle.  It has two attributesgrade(private) androadTax(public) with types respectively String and double types. The constructor of Vehicle class initializes grade and roadTax with 'this' reference keyword. There is one abstract method named double totalTax() . The classes that extend Vehicle arePublicVehicleandPrivateVehicle which have the following attributes. Observe that the subclasses have overridden totalTax() method. For a PublicVehicle totalTax is= 2* (fitnessTax+roadTax) and for a PrivateVehicle, totalTax is= 2.5* (fitnessTax+roadTax+10.2)



class PublicVehicle extends Vehicle{
private double fitnessTax;
PublicVehicle(String grade, double roadTax, double fitnessTax) { //assign the variables
}
@Override
double totalTax() { //calculate total tax and return the value.
}
}


class PrivateVehicle extends Vehicle{
private double fitnessTax;
PrivateVehicle(String grade, double roadTax, double fitnessTax) { //assign the variables
}


@Override
double totalTax() {//calculate total tax and return the value.}}
Now in the main class, create an array of type Vehicles and assign 3 different types of vehicles at different positions in the array. Take the information of the vehicles as inputs using Scanner.
Now print each of the vehicle's grade and total tax. You may implement printInfo() function in each subclass for efficient coding. You may write necessary getter/setter methods if necessary.



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here