CARATULA
INTEGRANTES
PÉREZ GÓMEZ OMAR ALEJANDRO
BALBUENA BECERRA ERIKO
MATERIA
TÓPICOS AVANZADOS DE PROGRAMACIÓN.
TEMA
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
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).
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(); }
/**
*/
@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);
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);
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()
.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();
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 */
/*
* 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);
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;
}
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 */
} }
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(); }
* 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);
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);
} });
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)
.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)
.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()
.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); }
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){
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())) {
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() {
} }); }
// 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;
/** *
* @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")
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°");
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");
} });
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()
.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(
.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))
);
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++;
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);
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())) {
} }
} 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() {
}); }
// 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;
*
* @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();
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");
} });
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");
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)
.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)
.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)
);
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));
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{
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;
} }
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); }
}); }
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;
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(); }
/**
* 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");
} });
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);
});
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()
.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()
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
* @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);
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;
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(); }
/**
* 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");
} });
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);
});
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()
.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()
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
* @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);
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;
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() {
}
/**
* 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");
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
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()
.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)) );
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))
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];
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);
}
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
/**
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);
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;