title: How do I get user input to allow another input after cycling through a loop?
body: <p>I'm fairly new to Java. I've done some C++ so I understand a lot of the concepts. I've been working on this code that allows me to ask for input on a tip calculator. I know some of the code is inconsistent but it's because I've been trying various methods to get it to display.</p>
  <p>I can go through the program once asking for user input. However when I loop through it again, it just displays the same input I put in prior. I'm trying to get it to show then loop through, take new input and display that. I've been teaching myself this so it's a learning experience for me, however I'm stumped and not sure where to go from here. Any help is appreciated.</p>
  <pre><code>import java.text.DecimalFormat;
  import java.text.NumberFormat;
  import java.util.InputMismatchException;
  import java.util.Scanner;
  
  public class TipApp {
  
      public static void main(String[] args) {
          calculateTips();
      }
  
      public static void calculateTips () {
          Scanner input = new Scanner(System.in);
          Scanner scan = new Scanner(System.in);
          String pattern = &quot;$##,###,###.00;&quot;; // Pattern string for the decimal format
          DecimalFormat moneyFormat = new DecimalFormat(pattern); // Decimal Money format
          NumberFormat defaultFormat = NumberFormat.getPercentInstance();
          defaultFormat.setMinimumFractionDigits(1);
          String choice;
          double theBill;
          int theTip;
          int thePartySize;
          boolean isBillValid = true;
          boolean isTipValid = true;
          boolean isPartySizeValid = true;
          TipCalculator tipCalculator1 = new TipCalculator();
          System.out.println(&quot;*** Tip Calculator ***&quot;);
  
          do {
              System.out.print(&quot;\nEnter the bill amount: &quot;);
              while (isBillValid) {
                  try {
                      if (input.hasNextDouble()) {
                          theBill = input.nextDouble();
                          isBillValid = false;
                          tipCalculator1.setBillAmount(theBill);
                      }
                  } catch (InputMismatchException e) {
                      System.out.println(input.next() + &quot; is not a valid number&quot;);
                  }
                  input.nextLine();
              }
  
              System.out.print(&quot;Enter your desired tip percentage (20 equals 20%): &quot;);
              while (isTipValid) {
                  if (input.hasNextInt()) {
                      theTip = input.nextInt();
                      isTipValid = false;
                      tipCalculator1.setTipPercentage(theTip);
                  } else {
                      System.out.println(&quot;Please enter a valid tip percentage.&quot;);
                      isTipValid = true;
                  }
                  input.nextLine();
              }
  
              System.out.print(&quot;Enter the size of your party: &quot;);
              while (isPartySizeValid) {
                  if (input.hasNextInt()) {
                      thePartySize = input.nextInt();
                      isPartySizeValid = false;
                      tipCalculator1.setPartyAmount(thePartySize);
                  } else {
                      System.out.println(&quot;Please enter a valid party size.&quot;);
                      isPartySizeValid = true;
                  }
                  input.nextLine();
              }
  
              System.out.println(&quot;*** Your Bill ***&quot;);
              System.out.print(&quot;\nBill Amount: &quot;);
              System.out.println(moneyFormat.format(tipCalculator1.getBillAmount()));
              System.out.print(&quot;Tip Percentage: &quot;);
              System.out.println(defaultFormat.format(tipCalculator1.getTipPercentage()));
              System.out.print(&quot;Party Size: &quot;);
              System.out.println(tipCalculator1.getPartyAmount());
              System.out.print(&quot;\nTotal Bill (with Tip): &quot;);
              System.out.print(moneyFormat.format(tipCalculator1.getTotalAmount()));
              System.out.print(&quot;\nShare for Each Individual: &quot;);
              System.out.print(moneyFormat.format(tipCalculator1.getIndividualShare()));
              System.out.print(&quot;\nAnother Bill? (y/n): &quot;);
              choice = scan.nextLine();
  
          } while (choice.equalsIgnoreCase(&quot;y&quot;)) ;
          System.out.println(&quot;\nGoodbye!&quot;);
      }
  }
  
  public class TipCalculator {
      private double billAmount;
      private int tipPercentage;
      private int partyAmount;
  
  
      // Constructor that holds 3 arguments
      public TipCalculator() {
          setBillAmount(billAmount);
          setTipPercentage(tipPercentage);
          setPartyAmount(partyAmount);
      }
  
      public double getBillAmount() {
          return billAmount;
      }
  
      public void setBillAmount(double billAmount) {
          this.billAmount = billAmount;
      }
  
      public double getTipPercentage() {
          return tipPercentage / 100f;
      }
  
      public void setTipPercentage(int tipPercentage) {
          this.tipPercentage = tipPercentage;
      }
  
      public int getPartyAmount() {
          return partyAmount;
      }
  
      public void setPartyAmount(int partyAmount) {
          this.partyAmount = partyAmount;
      }
  
      public double getIndividualShare() {
          return (getTotalAmount() / partyAmount);
      }
  
      public double getTotalAmount() {
          return (billAmount * getTipPercentage()) + billAmount;
      }
  }
  
    [1]: https://i.stack.imgur.com/5tHIs.png
  </code></pre>