Tarea de applets
1.-Realice un applet el cual permita introducir 3 números y muestre el mayor de los 3 números.
import java.applet.Applet;
import java.awt.*;
class May_3 extends Applet
{TextField t1 = new TextField ();
TextField t2 = new TextField ();
TextField t3 = new TextField ();
TextField ma = new TextField ();
Button b = new Button ("Mayor");
public voidinit ()
{
setLayout (null);
add (t1);
t1.setSize (40, 20);
t1.setLocation (30, 30);
add (t2);
t2.setSize (40, 20);
t2.setLocation(30, 70);
add (b);
b.setSize (40, 20);
b.setLocation (80, 50);
add (t3);
t3.setSize (40, 20);
t3.setLocation (30, 50);
add (ma);ma.setSize (40, 20);
ma.setLocation (150, 50);
}
public boolean action (Event e, Object o)
{
if (e.target == b)
{
int a = Integer.parseInt(t1.getText ());
int b = Integer.parseInt (t2.getText ());
int c = Integer.parseInt (t3.getText ());
if (a < b)
a = b;
if (a <c)
a = c;
ma.setText (a + "");
}
return true;
}
}
2. Realice un programa que permita insertar dos datos en formato hora y muestre un tercerotambién en formato hora el cual muestre la diferencia entre ambos datos.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class May_3 extends Applet
{
TextField t1 = newTextField ();
TextField t2 = new TextField ();
TextField t3 = new TextField ();
Button b1 = new Button ("Diferencia");
public void init ()
{
setLayout (null);add (t1);
t1.setSize (70, 20);
t1.setLocation (30, 30);
add (t2);
t2.setSize (70, 20);
t2.setLocation (30, 70);
add (b1);...
Regístrate para leer el documento completo.