dimanche 17 janvier 2021

If statements inside of Constructor keeps giving errors [duplicate]

My assignment is that I have to write some constructors and call them. I need to set schools with if statements depending on the value of gLevel. I keep getting the errors "illegal start of type", "illegal start of expression", and it says I'm missing parenthesis. May someone please take a look? The variables firstName, lastName, gradeLevel, and school are already preassigned.

Thank you so much.

public Student(String priName, String endName, int gLevel, String schools)
   {
     firstName = priName;
     lastName = endName;
     gradeLevel = gLevel;
       if (gLevel >= 9 && < 13)
     {
        schools = "high school";
     }
    else if (gLevel >= 6 && < 9)
    {
        schools = "middle school";
    }
    else if (gLevel < 6)
    {
        schools = "elementary school";
    }
   }

Aucun commentaire:

Enregistrer un commentaire