title: How to use while loop, for loop to replace this do-while loop.
body: <pre><code>import javax.swing.JOptionPane;
  
  
  public class SampleLT1 {
  
      public static void main(String[] args) {
          double dAllowance;
          int days;
  
          String strDAllowance, strDays;
          do{
              strDAllowance = JOptionPane.showInputDialog(null,"Please enter Daily Allowance $:(&gt;0)",
                  "Allowance", JOptionPane.INFORMATION_MESSAGE);
              dAllowance = Double.parseDouble(strDAllowance);
              if (dAllowance&lt;0) System.out.println("Daily Allowance shoould be &gt;0. Please enter again.");
              if (dAllowance==0) {//if enter daily Allowance as 0, exit the program
                  System.out.println("Thank you for using Allowance Calculating Application.");
                  System.exit(0);
              }
          }while (dAllowance&lt;0);//if daily allowance is smaller than 0, enter again
  
          do{
              strDays = JOptionPane.showInputDialog(null,"Please enter No. of working days: (&gt;0 and &lt;42)",
                  "Allowance", JOptionPane.INFORMATION_MESSAGE);
              days = Integer.parseInt(strDays);
              if(days&lt;0 || days&gt;42) System.out.println("No. of working days should &gt;0 and &lt;42. Please enter again.");
              if (days==0) {//enter 0 to quit the program
                  System.out.println("Thank you for using Allowance Calculating Application.");
                  System.exit(0);
              }
          }while (days&lt;0 || days&gt;42);//if days &lt;0 or &gt;42, enter days again
          System.out.println("For an internship student who worked "+days +" days with daily allowance $"+dAllowance+", his total allowance is $"+calAllowance(dAllowance,days));
          System.exit(0);
      }
  
      public static double calAllowance(double dailyAllowance, int noOfDays){
          return dailyAllowance * noOfDays;//calculate and return total allowance
      }
      }
  </code></pre>
  
  <p>How do I use while loop, for loop to replace this do-while loop?<br>
  Can anyone teach me? Need to know for my upcoming test.</p>