Question: Write a program in Java to compute the average gas mileage of automobiles. The program must have the following: A class named Automobile ( library
Write a program in Java to compute the average gas mileage of automobiles. The program must
have the following:
A class named Automobile library with the following:
One constructor initializes the model year only.
One method is to set the gas mileage.
One method to compute the average gas mileage.
One method to show the output average gas mileage is named
ShowAvgMileage.
One class named Sedan inherits Automobile class along with additional methods as
follows:
Override the ShowAvgMileage method of a superclass by adding the phrase "for
a sedan", as shown in Sample Output.
One class named Minivan also inherits Automobile class along with the following:
Override the ShowAvgMileage method of a superclass by adding the phrase "for
a minivan", as shown in Sample Output.
One class named FamilySedan inherits Sedan class along with the following:
Override the ShowAvgMileage method of a superclass by adding the phrase "for
a family sedan", as shown in Sample Output.
The Main function will stay in another class from where the constructors and all other
methods will be invoked through objects named: famSedof FamilySedan class
famSedof FamilySedan class and minivan of Minivan class
Inputs are to be taken inside the Main function from the user. The program will show the
outputs on the screen.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
