I am new to coding so bear with me. In my code, I am getting an illegal start of type error in my for loop (located in the student class). How can I fix this error?
In my for loop, I want to have my array grades have 10 values (which is already defined), and these values will be random from 60 to 99. In my opinion, I think that part is correct, and throughout I have used correct methodology. So if anybody can see where I have gone wrong I would be very grateful :)
import javax.swing.*;
public class StudentBase
{
public static void main(String[] args){
StudentBase app = new StudentBase();
app.go();
}
void go(){
//this is the main routine
JOptionPane.showMessageDialog(null, "Welcome!" + '\n');
String n = JOptionPane.showInputDialog("Type in your name");
JOptionPane.showMessageDialog(null, "Press ok if your name is" + " " + n);
String h = JOptionPane.showInputDialog("What is your height? (in meters: eg - 1.80)");
JOptionPane.showMessageDialog(null, "Press ok if your height is" + " " + h + " " + "meters");
JOptionPane.showMessageDialog(null, "Introduction to student class:" + " " + "Hello! My name is" + " " + n + " " + "and I am" + " " + h + " " + "meters tall.");
String students[] = new String [20];
JOptionPane.showMessageDialog(null, students);
}
}
//this is where Student Class is defined
class Student{
//add variables, constructors and methods here
String name = "";
String height = "";
int grades [] =new int [10];
for(i = 0; i < grades.length; i++)
{
grades[i] = rand(60,99);
}
public Student(String n, String h, int g[])
{
name = n;
height = h;
grades = g;
}
}