import java.awt.*; import java.awt.*; import java.applet.Applet; import java.awt.event.*; public class Banco2 extends Applet implements ActionListener { private TextField ingresado, interesanual, meses, interesesficticio, retencion, interescobrado; private double mesesdouble; private double retenciondouble, interescobradodouble, interesesficticiodouble, interesanualdouble, ingresadodouble; private Button calculo; public void init() { setBackground(Color.blue); Label etiq_titulo = new Label("Calculo de intereses"); etiq_titulo.setFont(new Font("Comic Sams MS", Font.ITALIC, 35)); etiq_titulo.setBackground(Color.red); add(etiq_titulo); Label etiq_ingresado = new Label("Dinero ingresado:"); etiq_ingresado.setFont(new Font("Times New Roman", Font.BOLD, 26)); add(etiq_ingresado); ingresado = new TextField(8); add(ingresado); Label etiq_interesanual = new Label("Interés anual:"); etiq_interesanual.setFont(new Font("Times New Roman", Font.BOLD, 26)); add(etiq_interesanual); interesanual = new TextField(8); add(interesanual); Label etiq_meses = new Label("Número de meses:"); etiq_meses.setFont(new Font("Times New Roman", Font.BOLD, 26)); add(etiq_meses); meses = new TextField(8); add(meses); calculo = new Button ("Calcula"); add(calculo); calculo.addActionListener(this); Label etiq_interesficticio = new Label("Interes:"); etiq_interesficticio.setFont(new Font("Times New Roman", Font.ITALIC, 26)); etiq_interesficticio.setForeground(Color.red); add(etiq_interesficticio); interesesficticio = new TextField(20); interesesficticio.setEditable(false); add(interesesficticio); Label etiq_retencion = new Label("Retencion:"); etiq_retencion.setFont(new Font("Times New Roman", Font.ITALIC, 26)); etiq_retencion.setForeground(Color.red); add(etiq_retencion); retencion = new TextField(20); retencion.setEditable(false); add(retencion); Label etiq_interescobrado = new Label("Interes cobrado:"); etiq_interescobrado.setFont(new Font("Times New Roman", Font.ITALIC, 26)); etiq_interescobrado.setForeground(Color.red); add(etiq_interescobrado); interescobrado = new TextField(20); interescobrado.setEditable(false); add(interescobrado); } public void paint(Graphics g) { double interesficticiodouble = ingresadodouble * ((mesesdouble/12) * interesanualdouble / 100); double retenciondouble = interesficticiodouble * 0.18; double interescobradodouble = interesficticiodouble - retenciondouble; String mensaje1 = Double.toString(interesficticiodouble); interesesficticio.setText(mensaje1); String mensaje2 = Double.toString(retenciondouble); retencion.setText(mensaje2); String mensaje3 = Double.toString(interescobradodouble); interescobrado.setText(mensaje3); } public void actionPerformed(ActionEvent event) { try { ingresadodouble = Double.parseDouble(ingresado.getText()); interesanualdouble = Double.parseDouble(interesanual.getText()); mesesdouble = Double.parseDouble(meses.getText()); repaint(); } catch(NumberFormatException e) { interesesficticio.setText("Solo se aceptan números"); } } }