Practicas en netbeans

Solo disponible en BuenasTareas
  • Páginas : 2 (262 palabras )
  • Descarga(s) : 0
  • Publicado : 6 de octubre de 2010
Leer documento completo
Vista previa del texto
Rectángulo
import javax.swing.*;
public class rectangulo {
public int base,altura;
public void CalcularArea( ){
base = Integer.parseInt(JOptionPane.showInputDialog(null,"Dame la base:"));altura = Integer.parseInt(JOptionPane.showInputDialog(null,"Dame la altura:"));
JOptionPane.showMessageDialog(null,"El area es:"+(base*altura));
}
public static void main (String[]arg){
rectangulore= new rectangulo( );
re.CalcularArea( );
}
}

Circulo
import javax.swing.*;
public class ciculo {
public int radio;
public float pi=3.1416f;
public void CalcularArea(){radio=Integer.parseInt(JOptionPane.showInputDialog(null,"Dame radio:"));
JOptionPane.showMessageDialog(null,"El area es:"+(pi*(radio*radio)));
}
public static void main (String []arg){
ciculo cir =new ciculo();cir.CalcularArea();
}
}

Promedio
import javax.swing.*;
public class promedio{
public int calif1;
public int calif2;
public int calif3;
public int calif4;
public int calif5;
publicvoid CalcularPromedio(){
calif1 = Integer.parseInt(JOptionPane.showInputDialog (null,"Dame Calificacion 1"));
calif2 = Integer.parseInt(JOptionPane.showInputDialog (null,"Dame Calificacion 2"));calif3 = Integer.parseInt(JOptionPane.showInputDialog (null,"Dame Calificacion 3"));
calif4 = Integer.parseInt(JOptionPane.showInputDialog (null,"Dame Calificacion 4"));
calif5 =Integer.parseInt(JOptionPane.showInputDialog (null,"Dame Calificacion 5"));
JOptionPane.showMessageDialog(null,"Tu Promedio es:"+(calif1+calif2+calif3+calif4+calif5)/5);
}
public static void main (String[]arg){
promedio prom =new promedio();
prom.CalcularPromedio();
}
}

Grados
import javax.swing.*;
public class conversion {
public int C;
public int F;
public void conversion(){C=Integer.parseInt(JOptionPane.showInputDialog(null,"Dame ºC:"));
JOptionPane.showMessageDialog(null,"El resultado en ºF es:"+(C+1.8+32));
F=Integer.parseInt(JOptionPane.showInputDialog(null,"Dame ºF:"));...
tracking img