I am creating a member application using the scanner to input data into an array called memberList. The data is going into an object and then the object is being stored in the array. I am using string and integers in the object.
I am writing a method to change one of the string variables in the array from yes to no, it is whether the member has paid their fees or not.
I am trying to enter the members name by calling my getName method and using the setFeePaid to change the String to "yes" from "no".
There is something wrong with the loop, as it only lets me change the first member in the array. Could anyone help please.
public static void payMemberYearlyFees(){
for (int i=0; i < memberCount; i++) {
Member member = memberList[i];
System.out.println("Enter the name of the member who has to pay their fee:");
if (input.nextLine().equals(member.getName())) {
member.setFeePaid("yes");
System.out.println();
System.out.println(member.getName() +" has paid their membership fee.\n");
System.out.println("********Returning to Main Menu.********\n");
}
else{
System.out.println();
break;
}
}
}