title: How to reset the value of a double, int, float etc after an "Incorrect" input by the user
body: <p>My question is in relation to my line of code resembling an ATM. The current balance being <code>10000</code>, What i have written shows a message to the user that if they withdraw over the given balance that it is <code>Insufficient balance</code>. However the balance continues to change thus when <code>Inquiring balance</code> the balance is now &lt; the allowed balance. My question is how should i go about resetting the double value for the balance when the <code>Insufficient balance</code> message is shown to the user?</p>
  <p>Here is my code.</p>
  <pre><code>import java.util.Scanner;
  
  class app {
    public static void main(String[] args)
    {
      long pin = 2927942074l;
      double balance = 10000.0;
      int attempts = 3;
  
      System.out.println(&quot;Please enter your pin.&quot;);
  
      while (attempts &gt; 0) {
      Scanner keyboardpin = new Scanner(System.in);
      long input = keyboardpin.nextLong();
  
      if (input == pin) {
            System.out.println(&quot;Correct&quot;);
            System.out.println(&quot;Welcome to your ATM&quot;);
          while (true) { // Keep printing your options unless &quot;Quit&quot; is chosen
  
            int a = 1;
            int b = 2;
            int c = 3;
            int d = 0;
  
              System.out.println(a + &quot; - Inquire Balance&quot;);
              System.out.println(b + &quot; - Withdraw&quot;);
              System.out.println(c + &quot; - Deposit&quot;);
              System.out.println(d + &quot; - Quit&quot;);
              System.out.println(&quot;Please select what you want to do.&quot;);
  
            Scanner menuselect = new Scanner(System.in);
            int menuinput = menuselect.nextInt();
  
            if (menuinput == a) {
                System.out.println(balance);
                continue;
            }
            if (menuinput == b) {
              System.out.println(&quot;Please enter a withdrawal amount.&quot;);
            Scanner withdrawamount = new Scanner(System.in);
            double withdrawbalace = withdrawamount.nextDouble();
            balance = (balance - withdrawbalace);
            if (withdrawbalace &gt; balance)
              System.out.println(&quot;Insufficient balance&quot;);
            if (withdrawbalace &lt;= balance)
              System.out.println(&quot;Youre new balance is &quot; + balance);
            }
            if (menuinput == c) {
  
            }
            if (menuinput == d) {
                break;
            }
        if (attempts == 0) {
            System.out.println(&quot;Maximum number of attempts exceeded&quot;);
            }
          }
        } else {
        System.out.println(&quot;Wrong&quot;);
        attempts--;
        System.out.println(&quot;You have &quot; + attempts + &quot; attempts remaining.&quot;);
        }
      }
    }
  }
  </code></pre>