Create a base class named Vehicle with instance variables….

$25.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

Create a base class named Vehicle with instance variables make (such as Ford, GM, Toyota, etc.), year , horsepower (200, 300, 400) and miles per gallon. Add the necessary constructor and set and get methods. Then create classes Bus and Truck.

Bus has an instance variable called numOfPassengers (1 to 50) and Truck has an instance variable called towingCapacity (0.5, 1.0, 2.0, 3.0 tons).

Both Bus and Truck inherit from Vehicle and have a method called calculateMPG. Create a program that displays all information about a specific bus and truck of your choice.

The formula for a bus’s milesPerGal is 10000/numOfPassengers/horsepower, but for a truck it is 5000/towingCapacity/horsepower.

Create a program that displays all information about a specific bus and truck of your choice.