PROMEDIO DE TRES NOTAS EN JAVA

INICIANDO EN JAVA
TRABAJAREMOS CON NETBEANS IDE 8.2


PRIMERA  PRACTICA:  PROMEDIO DE TRES NOTAS

anti clic en el proyecto y agregaremos un nuevo Jpanel como se muestra en la imagen



Insertaremosy trabajaremos con Label, Buttons, Textbox como muestra en la imagen y le cambiaremos los nombres.


Trabajaremos dentro de los botones

Código fuente: 


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

        // capturamoslos datos con String
        
        String nota1=txtnota1.getText();
        String nota2=txtnota2.getText();
        String nota3=txtnota3.getText();
        
        
        // Convertiremos los datos Ingresados
        
        double nnota1=Double.parseDouble(nota1);
        double nnota2=Double.parseDouble(nota2);
        double nnota3=Double.parseDouble(nota3);
        
        
        // el proceso
        
        double promedio;
        
        promedio=(nnota1+nnota2+nnota3)/3;
        
        // convertimos la respuesta a String
        
        String ppromedio=String.valueOf(promedio);
        
        // mostraremos el resultado en la caja de texto promedio
        
        txtpromedio.setText(ppromedio);
        
        
    }                                        

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // boton limpiar 
        
        txtnota1.setText("");
        txtnota2.setText("");
        txtnota3.setText("");
        txtpromedio.setText("");
        
    }                                        

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // boton cerrar
        
        dispose();
        
    }                                        



Share:

Anuncio de Enlaces

Buscar este blog

  • ()
  • ()
Mostrar más
Todos los derechos reservados por AITRAQUER. Con la tecnología de Blogger.

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Pages

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.