PREGUNTA 1
**********
[PARTE A]

class Triangulo extends Terna{

public Triangulo(){
super(); // a=b=c=0;
}

public boolean esTriangulo()[
return
a>0 && b>0 && c>0 &&
a+b>c && a+c>b && b+c>a;
}

public int ladosIguales(){
if (a==b && a==c)
return 3;
else if(a==b || a==c || b==c)
return 2;
else
return 0;
}

void graficar (String x){
....
....
}

}


[PARTE B]

int nt=0;
while(nt<100){
int a=(int)(Math.random()*100))+1;
int b=(int)(Math.random()*100))+1;
int c=(int)(Math.random()*100))+1;
Triangulo T=new Triangulo();
T.set1(a);
T.set2(b);
T.set3(c);
if(T.esTriangulo()){
++nt;
switch (T.ladosIguales()){
case 3: T.dibujar("rojo"); break;
case 2: T.dibujar("azul"); break;
case 0: T.dibujar("verde"); break;
}
}
}


PREGUNTA 2
**********

public class Recuento implements ActionListener{

private Label
L1 ,L2 ,L3 ;
private TextField
votos1,votos2,votos3;
private Button
cdto1,cdto2,descontar,recomenzar;
private int v1, v2, ultimoVoto;

Frame f=new Frame(); f.pack(); f.show();

public Recuento(){

L1 = new Label("Candidato");
L2 = new Label("N de Votos");
L3 = new Label("Total");

votos1 = new TextField("0");
votos2 = new TextField("0");
votos3 = new TextField("0");

cdto1 = new Button("Rosa Maria");
cdto2 = new Button("Jose Manuel");
descontar = new Button("Descontar ultimo voto");
recomenzar = new Button("Recomenzar");

v1=0; v2=0; ultimoVoto=0;

f.setLayout(new GridLayout(5,2));
f.add(L1); f.add(L2);
f.add(cdto1); f.add(votos1);
f.add(cdto2); f.add(votos2);
f.add(L3); f.add(votos3);
f.add(descontar); f.add(recomenzar);
cdto1.addActionListener(this);
cdto2.addActionListener(this);
descontar.addActionListener(this);
recomenzar.addActionListener(this);

}

static public void main(String []args){

new Recuento();

}

public void actionPerformed(ActionEvent x){
if(x.getSource() == cdto1){
++v1;
ultimoVoto=1;
}
else if(x.getSource() == cdto2){
++v2;
ultimoVoto=2;
}
else if(x.getSource() == recomenzar){
v1=v2=0;
}
else // descontar
if(ultimoVoto==1)
--v1;
else
--v2;
votos1.setText(""+v1);
votos2.setText(""+v2);
votos3.setText(""+(v1+v2));
}
}

PREGUNTA 3
**********

[PARTE A]

static public int reordenar (int n, int []x, int y){
int k=0;
for(int i=0; i<n; ++i)
if(x[i] % y == 0){
int aux=x[k];
x[k]=x[i];
x[i]=aux;
++k;
}
return k;
}

[PARTE B]

final int N=1000;
int []a = new int[N];
for(int i=0; i<N; ++i)
a[i] = i+1;

int n = reordenar(N,a,2);
n = reordenar(n,a,3);
n = reordenar(n,a,5);
// o int n=reordenar(N,a,2*3*5);

for(int i=0;i<n;++i)
System.out.println(a[i]);