title: How can I make a float throw an exception, when entered?
body: <p>I have a GUI that I use as a calculator. When I enter in anything other than numbers, it throws a NumberFormatException, as intended. But when I enter in a number such as "23423f" the program seems to think I'm entering a float and doesn't throw an exception, because of the f at the end, even though all other letters throw an exception.</p>
  
  <p>Currently, all I'm doing is putting the input section into a try catch block, where I parse it into a double, and having it catch a NumberFormatException if there is one (because only numbers can be parsed into doubles), and another catch block to throw an IllegalArgumentException from an if statement for any input less than 0.</p>
  
  <p>That's just a guess, but I don't know why else only f at the end wouldn't throw an exception.</p>
  
  <pre><code>        try
          {
          // get the total sales. the input is a string
             stringInput = salesInputField.getText();
                  double validAmount = Double.parseDouble(stringInput);
                  if (validAmount &lt; 0)
                      throw new IllegalArgumentException();
  
          // calculate the sales and county tax
             stateTaxes = validAmount * STATE_TAX;
             countyTaxes = validAmount * COUNTY_TAX;
  
          // display a message dialog showing the miles
             JOptionPane.showMessageDialog(null, "State Sales Tax: " + percent.format(stateTaxes) + "\n" +
                                                  "County Sales Tax: " + percent.format(countyTaxes) + "\n",
                                                  "Taxes Owed",
                                                  JOptionPane.PLAIN_MESSAGE);
          }
             catch (NumberFormatException error)
             {
                JOptionPane.showMessageDialog(null, "Invalid Amount", "Input Error", JOptionPane.ERROR_MESSAGE);
             }
                  catch (IllegalArgumentException error)
             {
                JOptionPane.showMessageDialog(null, "Invalid Amount", "Input Error", JOptionPane.ERROR_MESSAGE);
             }
  </code></pre>