I am attempting to ask for a value and tax rate and multiple those together to get a amount owed. It works great if I use whole numbers but it will not work when using decimals.
package apples;
import javax.swing.JOptionPane;
class apples {
public static void main(String[] args) {
String fn = JOptionPane.showInputDialog("Enter assessment value");
String sn = JOptionPane.showInputDialog("Enter local tax rate");
int num1 = Integer.parseInt(fn);
int num2 = Integer.parseInt(sn);
int sum = num1 * num2;
JOptionPane.showMessageDialog(null, "Tax amount" +sum);
}
} I expected it to multiple .23 by the value entered but I get this.
Exception in thread "main" java.lang.NumberFormatException: For input string: ".23"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:654)
at java.base/java.lang.Integer.parseInt(Integer.java:786)
at apples.apples.main(apples.java:11)