Can you please finish the last method… package prac; import java.util.Scanner; import java.io.*; p

Can you please finish the last method…

package prac;
import java.util.Scanner;
import java.io.*;
  
public class Prac {

public static plant[] myFlowers = new plant[10];
public static void main(String[] args) throws IOException {
//create a domain with two attributes
//create an array of objects that the file has in it
//call methods in main
createArrayOfFlowers();
findTallestFlower();
printAllFlowers();
  

  
}
//create methods
public static void createArrayOfFlowers()throws IOException
{
File myFile = new File(“plants.txt”);
Scanner inFile = new Scanner(myFile);
int i = 0;
String name;
double height;
plant aPlant;

while (inFile.hasNext() && i
{
name = inFile.next();
height = inFile.nextDouble();
aPlant = new plant(name, height);
myFlowers[i] = aPlant;
i++;
}
inFile.close();

}
//create methods
public static void findTallestFlower()
{
double tallestHeight = myFlowers[0].getHeight();
int indexOfTallest = 0;
  
//getting first entry of my arrays of flowers
for (int i = 1; i
{
if(myFlowers[i].getHeight() > tallestHeight)
{
tallestHeight = myFlowers[i].getHeight();
indexOfTallest = i;
}
}
System.out.println(“The tallest plant had a height of “+tallestHeight);
System.out.println(“The tallest plant was “+myFlowers[indexOfTallest]);
}
//create methods
public static void printAllFlowers()
{
  
//find average height
}
}

 

Looking for a Similar Assignment? Hire our Top Uk Tutors while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Active Discount Code FREE15