The method I'm hoping to execute doesn't acknowledge whenever a "y" is inputed into the scanner. It doesn't execute the first part of the if statement, it immediately skips to the else. I'm not sure why it isn't working, is it because I have several scanners running at once? The goal is to use the for loop to store several answers into an array and then manipulate the array with another method. any help to why would be great!
private static float[] assignMarkArray = {0,0,0};
public static void setAssignMark(int index, float value) {
assignMarkArray[index] = value;
}
public static void setLabMark (int index, float value) {
labMarkArray[index] = value;
}
public static void enterAssignGrades() {
System.out.println("Do you have any assignment Marks? (y/n)");
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
if (input == "y"){
for(int q = 0; q < 3; q++) {
System.out.println("Do you have a mark for A" + (q+1) + "(y/n)");
Scanner sc2 = new Scanner(System.in);
String input2 = sc2.nextLine();
if (input2 == "y") {
System.out.println("Enter your A" + (q+1) + " mark (Out of 100%): " );
Scanner sc3 = new Scanner(System.in);
float gradeInput2 = sc3.nextFloat();
setAssignMark(q, gradeInput2);
}else if (q==3) {
sc.close();
sc2.close();
}
else{
setAssignMark(q, 0);
}
}
}
else{ System.out.println("There are no assignment grades to mark");
sc.close();
}
}