Question: Given the classes in problem 3, and the array of Vehicles below, write the static method, findMin which returns the lowest price of any Vehicle

 Given the classes in problem 3, and the array of Vehicles

Given the classes in problem 3, and the array of Vehicles below, write the static method, findMin which returns the lowest price of any Vehicle in the Array

******-------------------Vehicle Class in Problem 3------------------------------*******

class Vehicle { private String registrationNumber; private String ownerName; private double price; private int yearManufactured; public Vehicle() { registrationNumber=""; ownerName=""; price=0.0; yearManufactured=0; } public Vehicle(String registrationNumber, String ownerName, double price, int yearManufactured) { this.registrationNumber=registrationNumber; this.ownerName=ownerName; this.price=price; this.yearManufactured=yearManufactured; } public String getRegistrationNumber() { return registrationNumber; } public String getOwnerName() { return ownerName; } public double getPrice() { return price; } public int getYearManufactured() { return yearManufactured; } public void setRegistrationNumber(String registrationNumber) { this.registrationNumber=registrationNumber; } public void setOwnerName(String ownerName) { this.ownerName=ownerName; } public void setPrice(double price) { this.price=price; } public void setYearManufactured(int yearManufactured) { this.yearManufactured=yearManufactured; } public String toString() { return " Registration number:"+ registrationNumber +"  Owner Name:"+ownerName+"  Price:"+ price+"  year manufactured"+yearManufactured; } } class Car extends Vehicle{ private int numberOfDoors; public Car(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfDoors) { super(registrationNumber, ownerName, price, yearManufactured); this.numberOfDoors = numberOfDoors; } public int getNumberOfDoors() { return numberOfDoors; } @Override public String toString() { return "Car{" + "numberOfDoors=" + numberOfDoors + '}'; } public void setNumberOfDoors(int numberOfDoors) { this.numberOfDoors = numberOfDoors; } } class Truck extends Vehicle{ private int numberOfAxles; public Truck(String registrationNumber, String ownerName, double price, int yearManufactured, int numberOfAxles) { super(registrationNumber, ownerName, price, yearManufactured); this.numberOfAxles = numberOfAxles; } public int getNumberOfAxles() { return numberOfAxles; } public void setNumberOfAxles(int numberOfAxles) { this.numberOfAxles = numberOfAxles; } @Override public String toString() { return "Truck{" + "numberOfAxles=" + numberOfAxles + '}'; } } 

(5 points - Array of objects) Given the classes in problem 3, and the array of Vehicles below, write the static method, findMin which returns the lowest price of any Vehicle in the Array 4. Vehicle [I myVehicles new Vehicletl1001 public static double findMin(Vehicle [J theVehicles) / / Answer to #4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!