Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create class Car with below attributes: make model passengerCapacity onRoadPrice - Create another class CarDemo which has main method. Create another method getBestCar in
Create class Car with below attributes: make model passengerCapacity onRoadPrice - Create another class CarDemo which has main method. Create another method getBestCar in this class which will take four car objects and additional parameter as compareType. Value of this parameter can be 'c' or 'p', where 'c' stands for capacity of passengers and 'p' stands for on road price. This method will return make and model name for highest value of 'c' or 'p' (with - character in between. E.g for make - Hyundai and model - santro, method should return "Hyundai-santro"). Create four objects of Car class in main method and drive it through getBestCar method. Use inheritance to code this program.
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