I'm stuck on this bit of code I'm trying to do. I've got a program I'm working in Netbeans with a main java form and a JFrame that acts like a popup. The frame has a button which prints the value of what I've put in a Getter method in the main. The is no error in the code put once i run the program and click the button the program crashes and this is what i get:
"Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException:
empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)"
This is my code for the main: `
public void Iva(){
float tiv = Float.parseFloat(tiva); // tiva is a global, String type variable
if("Papeleria".equals(tiva)){
iva = (float) (tiv*0.16); // iva is a global Float type variable
}
if("Supermercado".equals(tiva)){
iva = (float) (tiv*0.12);
}
if("Supermercado".equals(tiva)){
iva = (float) (tiv*0.14);
}
ivi = Float.toString(iva); // ivi is a global, String type variable
}
public String getIva() {
Iva();
return ivi;
}
And this is what Ive got for the ActionPerformed in the Frame:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
/*taiva is the text area where i want to show iva
mainy is what i called the main's class*/
taiva.setText(mainy.getIva());
}