vendredi 26 juillet 2019

If Statement Providing Wrong Output

I coded a banking program. I'm at the point where the user must enter their pin, and it must be compared to their pin which is taken from a text file. The problem is, I have an if statement, and the condition is met, but it keeps giving me an the statement as if it was not met.

I've tried switch statements and even using a boolean value, but it does not work

public String getPin(){
return pin;
}

    String pin2 = lbl_Pin.getText();
    System.out.println(pin2);
    System.out.println(getPin());

//Allows the user to select what they want to do after they enter the 
correct pin
if(pin2.equals(String.valueOf(getPin()))) {
btn_SelectLoan.setEnabled(true);
btn_SelectWithdraw.setEnabled(true);
btn_SelectDeposit.setEnabled(true);
btn_Balance.setEnabled(true);
lbl_Loan.setVisible(true);
lbl_Withdraw.setVisible(true);
lbl_Deposit.setVisible(true);
lbl_Balance.setVisible(true);

    }
//Displays invalid if the pin is not correct
else{
lbl_Pin.setText("Invalid");
    }
}                                         

I enter the correct pin, I am sure of this as I displayed the correct pin as well as the entered pin, and they are the same, but an invalid answer is provided

Aucun commentaire:

Enregistrer un commentaire