LOS VIDEOS ESTAN EN http://www.youtube.com/user/rvnrodrigo
import javax.swing.*;
import java.awt.*;
public class basica
{
public static void main(String args[])
{
cal p1=new cal();//cree el objeto p1
p1.menu();
datos_personales c1=new datos_personales();
c1.datos();
c1.area_triangulo();
}
}
class cal
{
double a,b,s,r,m,d;
int opc;
public void menu()
{
opc=Integer.parseInt(JOptionPane.showInputDialog("1.-suma\n2.-resta\n3.-multi\n4.-divi"));
if(opc==1)
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
s=a+b;
JOptionPane.showMessageDialog(null, "LA SUMA ES: "+s);
}
if(opc==2)
{
resta();
}
if(opc==3)
{
multi();
}
if(opc==4)
{
divi();
}
if(opc<1 || opc>4)
{
JOptionPane.showMessageDialog(null,"QUE PARTE ENTENDISTE DEL 1 AL 4");
}
}
public void suma()
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
s=a+b;
JOptionPane.showMessageDialog(null, "LA SUMA ES: "+s);
}
public void resta()
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
r=a-b;
JOptionPane.showMessageDialog(null, "LA RESTA ES: "+r);
}
public void multi()
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
m=a*b;
JOptionPane.showMessageDialog(null, "LA MULTIPLICACION: "+m);
}
public void divi()
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
d=a/b;
JOptionPane.showMessageDialog(null, "LA DIVISION ES: "+d);
}
public void raiz()
{
a=Double.parseDouble(JOptionPane.showInputDialog("DAME A: "));
b=Double.parseDouble(JOptionPane.showInputDialog("DAME B: "));
s=Math.sqrt(a+b)-Math.sqrt(a*a)+Math.tan(a*b);
JOptionPane.showMessageDialog(null, "LA RAIZ ES: "+s);
}
public void todo()
{
suma();
resta();
multi();
divi();
raiz();
}
}
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario