LOS VIDEOS ESTAN EN http://www.youtube.com/user/rvnrodrigo
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class promedio2 extends JApplet implements ActionListener
{
JTextField t1,t2,t3,t4;
JButton b1,b2;
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
t1=new JTextField(10);
t2=new JTextField(10);
t3=new JTextField(15);
t4=new JTextField(15);
b1=new JButton("PROMEDIAR");
b2=new JButton("LIMPIAR");
c.add(t1);
c.add(t2);
c.add(t3);
c.add(t4);
c.add(b1);
c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
double a,b,r;
if(e.getSource()==b1)
{
a=Double.parseDouble(t1.getText());
b=Double.parseDouble(t2.getText());
if(a<0 || a>10 )
{
JOptionPane.showMessageDialog(null,"CALIFICACIÓN UNO ( NO VALIDA )");
t1.setText(" ");
t2.setText(" ");
}
if(b<0 || b>10 )
{
JOptionPane.showMessageDialog(null,"CALIFICACIÓN DOS ( NO VALIDA )");
t1.setText(" ");
t2.setText(" ");
}
if(a>=0 && a<=10 && b>=0 && b<=10)
{
r=(a+b)/2;
if(r>=0 && r<=5.9)
{
t3.setText(String.valueOf(r));
t4.setText("REPROBADO");
}//r
if(r>=6 && r<=10)
{
t3.setText(String.valueOf(r));
t4.setText("APROBADO");
}
}
}//boton
if(e.getSource()==b2)
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
}
}//ACTION
}//CLASE
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario