I have this code and always that I execute appears two messages. JOptionPane.showMessageDialog(null, "ERROR DE PENSION"); JOptionPane.showMessageDialog(null, "ERROR PROMEDIO");
I don't understand why. Because I put this messages only if I choose certain values. But even if I choose other values still keep going these 2 messages.
Please, help me understand why!!
int pension;
String categoria;
Double promedio;
Double descuento;
categoria = txtTP.getText().toString();
System.out.println("hola" +categoria);
if (categoria.equalsIgnoreCase("A"))
pension = 550;
else
if(categoria.equalsIgnoreCase("B"))
pension = 500;
else
if(categoria.equalsIgnoreCase("C"))
pension = 460;
else
if (categoria.equalsIgnoreCase("D"))
pension = 400;
else
pension = 0;
JOptionPane.showMessageDialog(null, "ERROR DE PENSION");
System.out.println(pension);
promedio = Double.parseDouble(txtP.getText());
if (promedio>0 && promedio<14)
descuento=0.00;
else if (promedio >=14 && promedio < 16)
descuento = 0.1;
else if (promedio >=16 && promedio <18 )
descuento = 0.12;
else if (promedio >=18 && promedio <=20)
descuento = 0.15;
else
descuento = 0.00;
JOptionPane.showMessageDialog(null, "ERROR PROMEDIO");
textM.setText("Tienes" +descuento +"% de rebaja");
Aucun commentaire:
Enregistrer un commentaire