IPA40
IPA40
make - String
model - String
year - int
price - double
findMostExpensiveCar method:
This method will take an array of Car objects as input.
The method will return the Car object with the highest price.
If the array is empty, the method should return null.
getCarByMakeAndModel method:
This method will take three input parameters - array of Car objects, make and model
(both strings).
The method will return the Car object that matches the make and model attributes
passed as parameters.
If no car with the given make and model is present in the array of car objects,
then the method should return null.
These above mentioned static methods should be called from the main method.
For findMostExpensiveCar method - The main method should print the make, model,
year and price of the returned Car object.
If the returned value is null then it should print "Sorry - No car is available".
For getCarByMakeAndModel method - The main method should print the year and price
of the returned Car object. If the returned
value is null then it should print "Sorry - No car is available".
Before calling these static methods in main, use Scanner object to read the values
of four Car objects referring attributes in
the above mentioned attribute sequence. Next, read the values for make and model.
Input:
-----------------
Mercedes
S-Class
2020
1250000
BMW
5-Series
2019
900000
Audi
A4
2022
800000
Jaguar
F-PACE
2021
1100000
Audi
A4
Output:
---------------------
Mercedes
S-Class
1250000.0
2020
2022
800000.0