You are on page 1of 2

import java.awt.

*;
import java.applet.*;
import java.awt.event.*;
public class AppletCiclos4 extends Applet implements
ActionListener {
Label l1, l2,l3;
TextField t1,t2,t3;
Button b;
TextArea ta;
public AppletCiclos4() {
l1 = new Label("Cantidad de numeros : ");
t1 = new TextField(8);
l2 = new Label("Suma");
t2 = new TextField(8);
ta= new TextArea(20,30);
b = new Button("Calcular");
add(l1);
add(t1);
add(l2);
add(t2);
add(b);
add(ta);
b. addActionListener(this);
}
public
int
int
int
int
for

void actionPerformed(ActionEvent ae) {


cant = Integer.parseInt(t1.getText());
mult = 3;
total;
acumu=0;
(int i = 1; i<= cant; i++) {
total=mult*i;
acumu=acumu+total;
ta.append(" "+ total +"\n");

}
t2.setText(" " +acumu+ "\n");
}