Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the classes in problem 3, and the array of Vehicles below, write the stati

ID: 3713350 • Letter: G

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 in the Array

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

(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:

Explanation / Answer

public class Vehicle {

   private String registrationNumber;

   private String ownerName;

   private double price;

   private int yearManufactured;

   Vehicle [] myVehicles = new Vehicle[100];

  

   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;

   }

public static double findMin(Vehicle[] theVehicles)

{

   double lowestPrice = Vehicles[0];

   for(int i=1; i<price.length;i++){

   if(Vehicles[i] < lowestPrice){

       lowestPrice = Vehicles[i];

       }  

   }

   return lowestPrice;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote