title: How can I get(report in message dialog JOPTION) the maximum tax value and corresponding name of the tax payer?
body: <p>When N tax payers have been entered, you will report the maximum tax value and the corresponding tax payer name. You need to declare a double variable for maximum tax and another String type variable for the corresponding tax payer name. Then inside the for loop, use an if statement to compare the assumed maximum tax value and current tax value.</p>
  
  <pre><code>import javax.swing.*; 
  public class Exercise1d
  {
  private static double computeTax(int income)
  {
      if (income &lt; 18200)
          {
              return 0;
  
          }
          else if(income &lt; 37000)
          {
              return ((income - 18200)* 0.19);
  
          }
          else if(income &lt; 87000)
          {
              return(3572 +(income - 37000)* 0.325);
  
          }
          else if(income &lt; 180000)
          {
              return(19822 +(income - 87000)* 0.37);
  
          }
          else
          {
              return (54232 + (income - 180000)*0.47);
  
      }
  }
  
    public static void main(String[] args)
    {
  JOptionPane.showMessageDialog(null,"Welcome to use Tax Computation System");
  
      String taxPayerName;
      int totalInc;
      double totalTax;
      final int N =3;
      double ave = 0;
      double maxTax;
      String maxName;
  
  for(int x = 0;x&lt;N;x++)
  {
      taxPayerName = JOptionPane.showInputDialog(null,"Enter tax payer name: ");
      totalInc = Integer.parseInt(JOptionPane.showInputDialog(null,"Enter income for "+ taxPayerName +": "));
      totalTax = computeTax(totalInc);
      JOptionPane.showMessageDialog(null,"The tax that "+taxPayerName+" has to pay is "+totalTax);
      ave += computeTax(totalInc);
  }
      double ave2 = ave/N;
      JOptionPane.showMessageDialog(null,"Tax average is "+ ave2);
    }
  }
  </code></pre>