I am new to Java programming. I have been trying to figure out this issue for days now. The first loop skips the if statements and gives me "invalid entry", subsequent runs are fine. I have watched numerous videos and have read multiple questions/answers but still can not figure it out.
Any help or hint is greatly appreciated. Thanks
Sorry about not posting the picture instead of the code.
package com.Class5;
import java.util.Scanner;
public class practice {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Number of loops");
int numberOfRuns=input.nextInt();
for(int i=0;i<=numberOfRuns;i++) {
String month;
System.out.println("What month were you born in?");
month=input.nextLine();
if(month.equalsIgnoreCase("December")||month.equalsIgnoreCase("January")||month.equalsIgnoreCase("February")) {
System.out.println("You were born in Winter");
}else if(month.equalsIgnoreCase("March")||month.equalsIgnoreCase("April")||month.equalsIgnoreCase("May")){
System.out.println("You were born in Spring");
}else if(month.equalsIgnoreCase("June")||month.equalsIgnoreCase("July")||month.equalsIgnoreCase("August")) {
System.out.println("You were born in Summer");
}else if(month.equalsIgnoreCase("September")||month.equalsIgnoreCase("October")||month.equalsIgnoreCase("November")) {
System.out.println("You were born in fall");
}else {
System.out.println("invalid entry");
}
}
}
}