I've looked around for answers for this but I cannot find it. My professor requires me to use an array.. not an arraylist
public static void main(String[] args) {
final int total = 30;
String[] animalType = new String[total];
Scanner input = new Scanner(System.in);
for (int x = 0; x < total; x++) {
System.out.println("Enter the type of animal " + x + 1);
animalType[x] = input.next();
for (int x1 = 0; x1 < total; x1++) {
System.out.println("Enter the weight of the animal " + (x1 + 1));
animalType[x1] = input.next();
}
input.close();
System.out.println("Your friends are");
for (int counter = 0; counter < total; counter++) {
System.out.println(animalType[counter] + "\n" + animalType[counter]);
}
}
}
The prompt is.. allow user to enter the type of the animal and the weight of the animal and then output the average weight by animal type. I'm new to java and do not know how to use arrays properly.
input.close();is unadvisableAnimal[].