Se puderem ajudar, quando realizo o calculo o valor do % aperece apenas 0,0 e nao o valor real que desejo. Obrigado.
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Abandono extends Applet implements ActionListener {
TextField entrada1,entrada2,saida;
Label label1,label2,label3;
Button botao;
JLabel lbl;
int num1,num2;
float div;
public void init(){
label1 = new Label("Abandonadas: ");
add(label1);
label1.setBackground(Color.yellow);
label1.setForeground(Color.magenta);
entrada1 = new TextField(5);
add(entrada1);
label2 = new Label("Atendidas: ");
add(label2);
label2.setBackground(Color.yellow);
label2.setForeground(Color.magenta);
entrada2 = new TextField(5);
add(entrada2);
label3 = new Label("Calculo : ");
add(label3);
label3.setBackground(Color.green);
label3.setForeground(Color.black);
saida = new TextField(20);
add(saida);
botao = new Button("Add");
add(botao);
botao.addActionListener(this);
lbl = new JLabel("Calculo do Abandono. ");
add(lbl);
setBackground(Color.yellow);
}
public void actionPerformed(ActionEvent ae){
try{
num1 = Integer.parseInt(entrada1.getText());
entrada1.setText("");
num2 = Integer.parseInt(entrada2.getText());
entrada2.setText("");
div = (num1/num2)*100;
saida.setText(Float.toString(div));
lbl.setForeground(Color.blue);
lbl.setText("Entre com um novo valor: "
+ saida.getText());
}
catch(NumberFormatException e){
lbl.setForeground(Color.red);
lbl.setText("Entre com um novo valor!");
}
}
}