• No se han encontrado resultados

Informe programas de valores centrales.

N/A
N/A
Protected

Academic year: 2020

Share "Informe programas de valores centrales."

Copied!
98
0
0

Texto completo

(1)

CARATULA

INTEGRANTES

PÉREZ GÓMEZ OMAR ALEJANDRO

BALBUENA BECERRA ERIKO

MATERIA

TÓPICOS AVANZADOS DE PROGRAMACIÓN.

TEMA

(2)

Diagrama de flojo

INICIO

Leer los datos para calcular los valores centrales de las distribuciones. Ingresar da tos para calcular valores

centrales

Realizando operaciones mediante las formulas

Imprime resultado de la: -La media.

-La mediana.

-Desviación estándar.

FINALIZADO

(3)

Pseudocódigo

1.- Comprender las formulas de Valores centrales.

2.- Declaramos las clase en publicas (globales).

3.- La clase fue MEDIDAS.

4.- La estruptura del programa se manejo con jframe.

5.- Utilizamos varianles int(enteras), double(decimals), string(tipo cadena).

6.- Utilizamos un ordenamiento de la burbuja.

7.- El programa admite 10 numeros si pasamos de ellos se bloquea la entrada de datos.

8.- Se agrego el boton para la function y un voton para salir (pregunta regresar al menu o

salir).

(4)

PROGRAMA VALORES CENTRALES PROGRAMACIÓN ESTRUCTURADA

MENU

/*

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas;

/** *

* @author ALEXANDRE */

public class MENU extends javax.swing.JFrame {

/**

* Creates new form MENU */

public MENU() { initComponents(); }

/**

(5)

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIDAS - ARITMETICAS");

setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPRIME UNA

OPCION", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(0, 0, 102))); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton1.setText("MEDIA");

jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);

(6)

jButton2.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton2.setText("MEDIANA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton3.setText("DESVIACION ESTANDAR");

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt);

} });

jButton4.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton4.setText("SALIR");

jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt);

(7)

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addGap(24, 24, 24)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton3))

.addContainerGap(27, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

(8)

.addComponent(jButton4)

.addContainerGap(20, Short.MAX_VALUE)) );

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addGap(19, 19, 19)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(18, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(22, Short.MAX_VALUE))

);

pack();

(9)

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

this.setVisible(false);

new MEDIA().setVisible(true);

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

this.setVisible(false);

new MEDIANA().setVisible(true);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

this.setVisible(false);

new DESVIACIONESTANDAR().setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

System.exit(0);

}//GEN-LAST:event_jButton4ActionPerformed

/**

* @param args the command line arguments */

(10)

/*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

} }

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

(11)

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MENU().setVisible(true); }

}); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JPanel jPanel1;

(12)

}

MEDIDAS

/*

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas;

import javax.swing.*;

public class MEDIDAS {

static { try{

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception E){

} }

/**

* @param args the command line arguments */

(13)

} }

MEDIANA

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas;

import javax.swing.JOptionPane;

/** *

* @author ALEXANDRE */

public class MEDIANA extends javax.swing.JFrame { int numeros[] = new int[10];

int i=0,sum; Double total;

String entrada="",salida="",resultado="";

public MEDIANA() { initComponents(); }

(14)

* This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIANA");

setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N setResizable(false);

(15)

javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(0, 0, 255))); // NOI18N

jLabel1.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jLabel1.setForeground(new java.awt.Color(0, 0, 255));

jLabel1.setText("N°");

jTextField1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N jButton1.setText("SIGUIENTE");

jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);

} });

jButton2.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton2.setText("MEDIANA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

(16)

jButton3.setText("SALIR");

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt);

} });

jLabel2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel2.setText("DATOS ORDENADOS :");

jLabel3.setFont(new java.awt.Font("Georgia", 1, 10)); // NOI18N

jLabel4.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel4.setText("LA MEDIANA ES :");

jLabel5.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addGap(23, 23, 23)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

(17)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING, false)

.addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3))

.addComponent(jLabel2)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1))

.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(31, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

(18)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1))

.addGap(18, 18, 18) .addComponent(jLabel2) .addGap(18, 18, 18)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18) .addComponent(jLabel4) .addGap(18, 18, 18)

.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE) .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jButton2) .addComponent(jButton3)) .addContainerGap())

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

(19)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(18, Short.MAX_VALUE))

);

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

numeros[i]= Integer.parseInt( jTextField1.getText()); entrada+=" "+ numeros[i];

i++;

jTextField1.setText(""); if (i==10){

jTextField1.setEditable(false); jButton1.setEnabled(false); }

(20)

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

for(int pass=1; pass < 10; pass++){ for(int i=0; i < 10-pass; i++){ if(numeros [i] < numeros [i+1]){ int temp = numeros[i];

numeros [i] = numeros [i+1]; numeros [i+1] = temp; }

} }

for(int i=0;i<10;i++ ){

salida+= numeros[i] + " , "; }

total = (double)( numeros[0]+ numeros[9])/2; resultado = String.valueOf(total);

jLabel3.setText(salida); jLabel5.setText(resultado);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

int o = (int) JOptionPane.showConfirmDialog( null,"DESEAS REGRESAR AL MENU PRINCIPAL", "AVISO",JOptionPane.YES_NO_OPTION);

if(o== 0){

(21)

new MENU().setVisible(true); }

else{

this.setVisible(false); System.exit(0); }

}//GEN-LAST:event_jButton3ActionPerformed

/**

* @param args the command line arguments */

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

(22)

break; }

}

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

(23)

} }); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JTextField jTextField1;

// End of variables declaration//GEN-END:variables }

MEDIA

/*

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas;

(24)

/** *

* @author ALEXANDRE */

public class MEDIA extends javax.swing.JFrame { int numeros[] = new int[10];

int i=0,sum; Double total;

String entrada="",salida="",resultado=""; /**

* Creates new form MEDIA */

public MEDIA() { initComponents(); }

/**

* This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

(25)

jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel();

jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIA");

setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INTRODUCE LOS NUMEROS", javax.swing.border.TitledBorder.CENTER,

javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(0, 0, 102))); // NOI18N

jLabel1.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jLabel1.setForeground(new java.awt.Color(0, 0, 255));

jLabel1.setText("N°");

(26)

jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);

} });

jTextField1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N

jTextField1.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));

jLabel2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel2.setText("DATOS INSERTADOS :");

jButton2.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton2.setText("MEDIA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton3.setText("SALIR");

(27)

} });

jLabel3.setFont(new java.awt.Font("Georgia", 1, 10)); // NOI18N jLabel3.setForeground(new java.awt.Color(0, 0, 255));

jLabel4.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel4.setText("LA MEDIA ES :");

jLabel5.setFont(new java.awt.Font("Georgia", 1, 13)); // NOI18N

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addGroup(jPanel1Layout.createSequentialGroup() .addGap(32, 32, 32)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L EADING)

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup()

(28)

.addComponent(jButton3))))

.addGroup(jPanel1Layout.createSequentialGroup() .addGap(108, 108, 108)

.addComponent(jLabel5))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addGap(31, 31, 31)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton1))) .addContainerGap())

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addGap(0, 31, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addComponent(jLabel4)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(27, 27, 27)) );

jPanel1Layout.setVerticalGroup(

(29)

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jButton1)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1))

.addGap(18, 18, 18) .addComponent(jLabel2) .addGap(18, 18, 18)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(25, 25, 25) .addComponent(jLabel4)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel5)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jButton2) .addComponent(jButton3)) .addGap(21, 21, 21))

);

(30)

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(23, Short.MAX_VALUE))

);

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

numeros[i]= Integer.parseInt( jTextField1.getText()); entrada+=" "+ numeros[i];

i++;

(31)

jTextField1.setEditable(false); jButton1.setEnabled(false); }

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

for(int i=0;i<10;i++){

salida+= numeros[i] + " , "; }

for(int i=0;i<10;i++ ){ sum+=numeros[i]; }

total = (double)sum/10;

resultado = String.valueOf(total); jLabel3.setText(salida);

jLabel5.setText(resultado);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

int o = (int) JOptionPane.showConfirmDialog( null,"DESEAS REGRESAR AL MENU PRINCIPAL", "AVISO",JOptionPane.YES_NO_OPTION);

if(o== 0){

this.setVisible(false);

(32)

else{

this.setVisible(false); System.exit(0); }

}//GEN-LAST:event_jButton3ActionPerformed

/**

* @param args the command line arguments */

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

(33)

} }

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MEDIA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(MEDIA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(MEDIA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MEDIA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

(34)

}); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JTextField jTextField1;

// End of variables declaration//GEN-END:variables }

DESVIACIONES ESTANDAR

/*

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas;

import javax.swing.JOptionPane;

(35)

*

* @author ALEXANDRE */

public class DESVIACIONESTANDAR extends javax.swing.JFrame {

int numeros[] = new int[10]; int i=0,sum;

Double total,total1,total2,total3,total4,total5,total6,total7,total8,total9,total10,total11,ToFI; String entrada="",salida="",resultado="";

public DESVIACIONESTANDAR() { initComponents();

}

/**

* This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel();

(36)

jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("DESVIACION-ESTANDAR");

setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INTRODUCE LOS NUMEROS", javax.swing.border.TitledBorder.CENTER,

javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(0, 0, 255))); // NOI18N

jLabel1.setFont(new java.awt.Font("Georgia", 0, 14)); // NOI18N jLabel1.setText("N°");

jTextField1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N jButton1.setText("SIGUIENTE");

(37)

} });

jLabel2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel2.setText("DATOS INSERTADOS");

jLabel3.setFont(new java.awt.Font("Georgia", 1, 10)); // NOI18N

jLabel4.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N jLabel4.setText("LA DESVIACION ESTANDAR ES :");

jLabel5.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N

jButton2.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton2.setText("D.E.");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton3.setText("SALIR");

(38)

jButton3ActionPerformed(evt); }

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA ILING, false)

.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18) .addComponent(jButton1))

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)) .addComponent(jLabel4)

(39)

.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(29, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jLabel1)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1))

.addGap(18, 18, 18) .addComponent(jLabel2) .addGap(18, 18, 18)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)

(40)

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addComponent(jButton3) .addComponent(jButton2))

.addContainerGap(15, Short.MAX_VALUE)) );

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap()) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

(41)

);

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

for(int i=0;i<10;i++){

salida+= numeros[i] + " , "; }

for(int i=0;i<10;i++ ){ sum+=numeros[i]; }

total = (double)sum/10;

total1=(Math.pow((numeros[0]-total),2)); total2=(Math.pow((numeros[1]-total),2)); total3=(Math.pow((numeros[2]-total),2)); total4=(Math.pow((numeros[3]-total),2)); total5=(Math.pow((numeros[4]-total),2)); total6=(Math.pow((numeros[5]-total),2)); total7=(Math.pow((numeros[6]-total),2)); total8=(Math.pow((numeros[7]-total),2)); total9=(Math.pow((numeros[8]-total),2)); total10=(Math.pow((numeros[9]-total),2));

(42)

resultado = String.valueOf(Math.sqrt(ToFI)); jLabel3.setText(salida);

jLabel5.setText(resultado);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

numeros[i]= Integer.parseInt( jTextField1.getText()); entrada+=" "+ numeros[i];

i++;

jTextField1.setText(""); if (i==10){

jTextField1.setEditable(false); jButton1.setEnabled(false); }

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

int o = (int) JOptionPane.showConfirmDialog( null,"DESEAS REGRESAR AL MENU PRINCIPAL", "AVISO",JOptionPane.YES_NO_OPTION);

if(o== 0){

this.setVisible(false);

new MENU().setVisible(true); }

else{

(43)

System.exit(0); }

}//GEN-LAST:event_jButton3ActionPerformed

/**

* @param args the command line arguments */

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

} }

(44)

java.util.logging.Logger.getLogger(DESVIACIONESTANDAR.class.getName()).log(java.util.logging.Le vel.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(DESVIACIONESTANDAR.class.getName()).log(java.util.logging.Le vel.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(DESVIACIONESTANDAR.class.getName()).log(java.util.logging.Le vel.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(DESVIACIONESTANDAR.class.getName()).log(java.util.logging.Le vel.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new DESVIACIONESTANDAR().setVisible(true); }

}); }

(45)

private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JTextField jTextField1;

(46)

PROGRAMA VALORES CENTRALES PROGRAMACIÓN ORIENADA A

OBJETOS

CODIGO FUENTE

MENU

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas.poo;

/** *

* @author ALEXANDRE */

public class MENU extends javax.swing.JFrame {

/**

* Creates new form MENU */

public MENU() { initComponents(); }

/**

(47)

* WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIDAS-ARITMETICAS");

setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPRIMA UNA

OPCION", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(204, 0, 0))); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton1.setText("MEDIA");

(48)

} });

jButton2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton2.setText("MEDIANA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton3.setText("DESVIACION ESTANDAR");

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt);

} });

jButton4.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton4.setText("SALIR");

jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt);

(49)

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG, false)

.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

(50)

.addGap(18, 18, 18) .addComponent(jButton3) .addGap(18, 18, 18) .addComponent(jButton4)

.addContainerGap(19, Short.MAX_VALUE)) );

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

(51)

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

this.setVisible(false);

new MEDIA().setVisible(true);

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

this.setVisible(false);

new MEDIANA().setVisible(true);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

this.setVisible(false);

new DESVIACIONESTANDAR().setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

System.exit(0);

}//GEN-LAST:event_jButton4ActionPerformed

(52)

* @param args the command line arguments */

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

} }

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

(53)

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MENU().setVisible(true); }

}); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

(54)

private javax.swing.JButton jButton4; private javax.swing.JPanel jPanel1;

// End of variables declaration//GEN-END:variables }

MEDIDAS POO

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas.poo;

/** *

* @author ALEXANDRE */

public class MENU extends javax.swing.JFrame {

/**

* Creates new form MENU */

public MENU() { initComponents(); }

/**

(55)

* WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIDAS-ARITMETICAS");

setResizable(false);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPRIMA UNA

OPCION", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 1, 16), new java.awt.Color(204, 0, 0))); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton1.setText("MEDIA");

(56)

} });

jButton2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton2.setText("MEDIANA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton3.setText("DESVIACION ESTANDAR");

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt);

} });

jButton4.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jButton4.setText("SALIR");

jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt);

(57)

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG, false)

.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

(58)

.addGap(18, 18, 18) .addComponent(jButton3) .addGap(18, 18, 18) .addComponent(jButton4)

.addContainerGap(19, Short.MAX_VALUE)) );

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

(59)

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

this.setVisible(false);

new MEDIA().setVisible(true);

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

this.setVisible(false);

new MEDIANA().setVisible(true);

}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

this.setVisible(false);

new DESVIACIONESTANDAR().setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

System.exit(0);

}//GEN-LAST:event_jButton4ActionPerformed

(60)

* @param args the command line arguments */

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

} }

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

(61)

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MENU.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MENU().setVisible(true); }

}); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

(62)

private javax.swing.JButton jButton4; private javax.swing.JPanel jPanel1;

// End of variables declaration//GEN-END:variables }

MEDIANA

/*

* To change this template, choose Tools | Templates * and open the template in the editor.

*/

package medidas.poo;

import javax.swing.JOptionPane;

/** *

* @author ALEXANDRE */

public class MEDIANA extends javax.swing.JFrame {

int numeros[] = new int[10]; int i=0,sum;

Double total;

String entrada="",salida="",resultado=""; public MEDIANA() {

(63)

}

/**

* This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("MEDIANA");

(64)

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "INTRODUCE LOS NUEMROS", javax.swing.border.TitledBorder.CENTER,

javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Georgia", 0, 16), new java.awt.Color(204, 0, 0))); // NOI18N

jLabel1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N jLabel1.setForeground(new java.awt.Color(102, 0, 0));

jLabel1.setText("N°");

jTextField1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N

jButton1.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N jButton1.setText("SIGUIENTE");

jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);

} });

jLabel2.setFont(new java.awt.Font("Georgia", 1, 16)); // NOI18N jLabel2.setText("DATOS ORDENADOS :");

jLabel3.setFont(new java.awt.Font("Georgia", 1, 10)); // NOI18N

(65)

jLabel5.setFont(new java.awt.Font("Georgia", 1, 12)); // NOI18N

jButton2.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton2.setText("MEDIANA");

jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt);

} });

jButton3.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N jButton3.setText("SALIR");

jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt);

} });

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

(66)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG)

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA ILING, false)

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton1)))

.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3)))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

(67)

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jLabel1)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1))

.addGap(18, 18, 18) .addComponent(jLabel2) .addGap(18, 18, 18)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18) .addComponent(jLabel4) .addGap(18, 18, 18)

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASEL INE)

.addComponent(jButton2) .addComponent(jButton3))

(68)

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

pack();

}// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

numeros[i]= Integer.parseInt( jTextField1.getText()); entrada+=" "+ numeros[i];

(69)

jTextField1.setText(""); if (i==10){

jTextField1.setEditable(false); jButton1.setEnabled(false); }

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

Ordenar(numeros); Mostrar(numeros);

}//GEN-LAST:event_jButton2ActionPerformed

public void Ordenar(int A[]){

for(int pass=1; pass < 10; pass++){ for(int i=0; i < 10-pass; i++){ if(numeros [i] < numeros [i+1]){ int temp = numeros[i];

numeros [i] = numeros [i+1]; numeros [i+1] = temp; }

} }

total = (double)( numeros[0]+ numeros[9])/2; resultado = String.valueOf(total);

(70)

}

public void Mostrar(int B[]){ for(int i=0;i<10;i++ ){

salida+= numeros[i] + " , "; }

jLabel3.setText(salida); }

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

int o = (int) JOptionPane.showConfirmDialog( null,"DESEAS REGRESAR AL MENU PRINCIPAL", "AVISO",JOptionPane.YES_NO_OPTION);

if(o== 0){

this.setVisible(false);

new MENU().setVisible(true); }

else{

this.setVisible(false); System.exit(0); }

}//GEN-LAST:event_jButton3ActionPerformed

/**

(71)

public static void main(String args[]) { /*

* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /*

* If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see

* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */

try {

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName()); break;

} }

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

(72)

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(MEDIANA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

}

//</editor-fold>

/*

* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new MEDIANA().setVisible(true); }

}); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1;

Referencias

Documento similar

examining the degree of effectiveness of inclusive education programs in private, semi-private and public centers for the neurodiverse L2 classroom; exploring students’

• Supone una nueva adaptación, modificación y transformación de los elementos musicales debido a: los desplazamientos rítmicos de los ritmos aditivos, la polirrítmia y el swing

Promoverla a través de la negación de los hechos será una estrategia que también encontraremos en las controversias (socio)científicas sobre cuestiones medioambientales

Indeed, when the quality of the signal is high, agents receiving a good (bad) signal invest more (less) in the risky asset than uninformed ones, so that investment becomes

The existence of the long-run equilibrium relationship, between private and public investment, is tested. If this equilibrium relationship holds, it would imply

Swing speed Vitesse de rotation Potencia Power Puissance nécessaire Motor Engine Moteur Potencia Power Puissance Categoría Category Catégorie Anchura estabilizador Stabilizer

public class TestFrameworkClassLoader extends URLClassLoader{. private static

Focusing on regional variations, firms in Addis Ababa and Oromia account for both the largest number of firms in the survey (75%) and for over 70 percent of the total