I'm a beginner at Java and I'm creating a program that stores the names and weight of students in two different arrays after taking input from the user 30 times. Here's my code:
import java.util.Scanner;
public class bodymass {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
String[] studentName= new String[30];
System.out.println("Please enter the Names of 30 students");
// This "i" is your counter.
for (int i=0; i< studentName.length; i++) {
studentName[i]= scan.nextLine();}
System.out.println("Please enter the Weight of 30 students");
Scanner scan1= new Scanner(System.in);
int[] studentWeight= new int[30];
for(int i=0; i<studentWeight.length; i++) {
studentWeight[i]= scan.nextInt();}
}
}
However when I debug it, I get the message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: at bodymass.main(bodymass.java:5)
What does it mean? I would be grateful if somebody guides me through this.