I am making a bank machine code for a project and whenever you log in it gives an error. The part of the code that is doing it is this:
if(pincheck == pin){
loggedin = true;
pincheck = 0;
do{
System.out.println("Welcome, " + name);
System.out.println("");
System.out.println("Your account balance is $" + balance);
System.out.println("");
System.out.println("Press 1 to deposit funds");
System.out.println("Press 2 to withdraw funds");
System.out.println("Press 3 to log out");
System.out.println("");
options = in.nextInt();
switch (options) {
case 1: System.out.println("How much would you like to deposit?"); // deposit
deposit = in.nextFloat();
balance = balance + deposit;
deposit = 0;
System.out.println("You have deposited funds into your account."); // withdraw
System.out.println("");
break;
case 2: System.out.println("How much would you like to withdraw?");
withdraw = in.nextFloat();
balance = balance - withdraw;
withdraw = 0;
System.out.println("You have removed funds from your account.");
System.out.println("");
break;
case 3: System.out.println("Logging out..."); // log out
System.out.println("");
loggedin = false;
break;
default:System.out.println("Please enter a valid number"); // Invalid number
break;
}
}while(loggedin = true);
What is happening is to log in you need to put in a number, as pincheck, and if it is equal to the pin that exists it will log you in. I can log in but when I press 3 to log out, it prints logging out and than prints welcome and the whole thing starts again. Can anyone point out where I am getting stuck?