lunes, 23 de abril de 2007

hallar las raices de un polinomio de grado 2

/*
* NewJFrame.java
*
* Created on 16 de abril de 2007, 07:19 PM
*/

/**
*
* @author ALUMNO
*/
public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
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();
jScrollPane5 = new javax.swing.JScrollPane();
jTextPane5 = new javax.swing.JTextPane();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("a");

jTextPane1.setName("A");
jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setName("B");
jTextPane2.setName("B");
jScrollPane2.setViewportView(jTextPane2);

jTextPane3.setEditable(false);
jTextPane3.setName("R1");
jScrollPane3.setViewportView(jTextPane3);

jTextPane4.setEditable(false);
jTextPane4.setName("R2");
jScrollPane4.setViewportView(jTextPane4);

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

jLabel2.setText("b");

jLabel3.setText("Raiz 1");

jLabel4.setText("Raiz 2");

jLabel5.setText("c");

jTextPane5.setName("C");
jScrollPane5.setViewportView(jTextPane5);

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
.addContainerGap(306, Short.MAX_VALUE)
.add(jButton1)
.add(120, 120, 120))
.add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING,
layout.createSequentialGroup()
.add(21, 21, 21)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel5)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2)))
.add(14, 14, 14)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
false)
.add(jScrollPane5)
.add(jScrollPane2)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.addContainerGap()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel3)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(14, 14, 14)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 196,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(81, 81, 81)
.add(jLabel4)))
.addContainerGap())
);
layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(15, 15, 15)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.add(25, 25, 25)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel5)
.add(jScrollPane5,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel3)
.add(jLabel4))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
17, Short.MAX_VALUE)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,
false)
.add(org.jdesktop.layout.GroupLayout.LEADING,
jScrollPane4)
.add(org.jdesktop.layout.GroupLayout.LEADING,
jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 47,
Short.MAX_VALUE))
.add(21, 21, 21)
.add(jButton1)
.addContainerGap(49, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt)
{//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
double a, b, c;
double r1, r2;
String str1,str2;
a = Double.parseDouble(jTextPane1.getText());
b = Double.parseDouble(jTextPane2.getText());
c = Double.parseDouble(jTextPane5.getText());

r1=(-b+Math.sqrt(b*b-4*a*c))/(2*a);
r2=(-b-Math.sqrt(b*b-4*a*c))/(2*a);

str1 = String.valueOf(r1);
str2 = String.valueOf(r2);
jTextPane3.setText(str1);
jTextPane4.setText(str2);
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
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.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
private javax.swing.JTextPane jTextPane5;
// End of variables declaration//GEN-END:variables

}

hallar el MCD

/*
* UsoWhile.java
*
* Created on 17 de abril de 2007, 07:49 PM
*/

/**
*
* @author ALUMNO
*/
public class UsoWhile extends javax.swing.JFrame {

/** Creates new form UsoWhile */
public UsoWhile() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
jScrollPane5 = new javax.swing.JScrollPane();
jTextPane5 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setViewportView(jTextPane2);

jLabel1.setText("1er numero");

jLabel2.setText("2do Numero");

jScrollPane3.setViewportView(jTextPane3);

jScrollPane4.setViewportView(jTextPane4);

jScrollPane5.setViewportView(jTextPane5);

jLabel3.setText("MCD");

jLabel4.setText("N1");

jLabel5.setText("N2");

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

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
false)
.add(layout.createSequentialGroup()
.add(30, 30, 30)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2))
.add(14, 14, 14))

.add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()

..addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.add(jLabel3)
.add(23, 23, 23)))

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane5,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,
false)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)))

..addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 32,
Short.MAX_VALUE)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel4)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(20, 20, 20)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel5)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.add(150, 150, 150)
.add(jButton1)))
.addContainerGap())
);
layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

..addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.add(54, 54, 54)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane5,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3)))
.add(layout.createSequentialGroup()
.add(46, 46, 46)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(jLabel5))

..addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
40, Short.MAX_VALUE)
.add(jButton1)
.add(55, 55, 55))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt)
{//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
int A,B, r, MCD;
String strMCD, strA, strB;
A = Integer.parseInt(jTextPane1.getText());
B = Integer.parseInt(jTextPane2.getText());

strA = ""; strB = "";
while(B!=0){
strA += String.valueOf(A)+ "\n";
strB += String.valueOf(B)+ "\n";
r = A % B;
A = B;
B = r;
}
strA += String.valueOf(A)+ "\n";
strB += String.valueOf(B)+ "\n";
jTextPane3.setText(strA);
jTextPane4.setText(strB);
MCD = A;
strMCD = String.valueOf(MCD);
jTextPane5.setText(strMCD);
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UsoWhile().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
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.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
private javax.swing.JTextPane jTextPane5;
// End of variables declaration//GEN-END:variables

}

determinar si un numero es positivo, negativo o cero

import com.sun.org.apache.bcel.internal.verifier.statics.DOUBLE_Upper;
/*
* UsoIf.java
*
* Created on 17 de abril de 2007, 07:15 PM
*/

/**
*
* @author ALUMNO
*/
public class UsoIf extends javax.swing.JFrame {

/** Creates new form UsoIf */
public UsoIf() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jButton1 = new javax.swing.JButton();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jScrollPane1.setViewportView(jTextPane1);

jLabel1.setText("Numero");

jTextPane2.setEditable(false);
jScrollPane2.setViewportView(jTextPane2);

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

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(28, 28, 28)
.add(jLabel1)
.add(22, 22, 22)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 189,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 111,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.add(layout.createSequentialGroup()
.add(161, 161, 161)
.add(jButton1)))
.addContainerGap(124, Short.MAX_VALUE))
);
layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(31, 31, 31)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(64, 64, 64)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(57, 57, 57)
.add(jButton1)
.addContainerGap(77, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt)
{//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
double n;

n = Double.parseDouble(jTextPane1.getText());

if(n>0)
jTextPane2.setText("Numero Positivo");
else if(n<0)
jTextPane2.setText("Numero Negativo");
else
jTextPane2.setText("Numero es cero");

}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UsoIf().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
// End of variables declaration//GEN-END:variables

uso "for"

/*
* UsoFor.java
*
* Created on 17 de abril de 2007, 07:25 PM
*/

/**
*
* @author ALUMNO
*/
public class UsoFor extends javax.swing.JFrame {

/** Creates new form UsoFor */
public UsoFor() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Inicio");

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

jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setViewportView(jTextPane2);

jLabel2.setText("Paso");

jScrollPane3.setViewportView(jTextPane3);

jScrollPane4.setViewportView(jTextPane4);

jLabel3.setText("Nro Iteraciones");

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(33, 33, 33)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2))
.add(27, 27, 27)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(58, 58, 58)
.add(jButton1))
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,
false)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE))
.add(36, 36, 36)
.add(jLabel3)
.add(15, 15, 15)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(layout.createSequentialGroup()
.add(154, 154, 154)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(31, Short.MAX_VALUE))
);
layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(20, 20, 20)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
.add(18, 18, 18)
.add(jButton1)
.add(38, 38, 38))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt)
{//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
int i, v, vi, paso, ni;
String str;
vi = Integer.parseInt(jTextPane1.getText());
paso = Integer.parseInt(jTextPane2.getText());
ni = Integer.parseInt(jTextPane4.getText());

str="";
for(i=1, v=vi; i <= ni; i++){
str = str + String.valueOf(v)+"\n";
v = v + paso;
}
jTextPane3.setText(str);

}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UsoFor().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
// End of variables declaration//GEN-END:variables

}

tabla de proposiciones

/*
* logica.java
*
* Created on 23 de abril de 2007, 06:54 PM
*/

/**
*
* @author ALUMNO
*/
public class logica extends javax.swing.JFrame {

/** Creates new form logica */
public logica() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});

jScrollPane1.setViewportView(jTextPane1);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(23, 23, 23)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 346, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(31, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 264, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(25, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
String str;
boolean p,q,r1,r2;
int i,j;

str = "";
for(p=false,i=0; i<2; i++,p=true){
for(q=false,j=0; j<2; j++,q=true){
r1 = p && q;
r2 = p q;
str = str + String.valueOf(p)+" AND "+String.valueOf(q)+" = "+String.valueOf(r1);
str += "\t";
str = str + String.valueOf(p)+" OR "+String.valueOf(q)+" = "+String.valueOf(r2);
str += "\n";
}
}
jTextPane1.setText(str);

}//GEN-LAST:event_formWindowOpened

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new logica().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration//GEN-END:variables

}

suma de los N primeros numeros naturales

/*
* EjWhile.java
*
* Created on 23 de abril de 2007, 07:14 PM
*/

/**
*
* @author ALUMNO
*/
public class EjWhile extends javax.swing.JFrame {

/** Creates new form EjWhile */
public EjWhile() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("N");

jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setViewportView(jTextPane2);

jLabel2.setText("Suma");

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

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(20, 20, 20)
.add(jLabel1))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel2)))
.add(19, 19, 19)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 114, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(223, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(178, Short.MAX_VALUE)
.add(jButton1)
.add(149, 149, 149))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(15, 15, 15)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(34, 34, 34)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.add(41, 41, 41)
.add(jButton1)
.addContainerGap(54, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
int n,i,S;
n = Integer.parseInt(jTextPane1.getText());

S = 0; i = 0;
while(i<=n){
S = S + i;
i++; // i = i + 1
}
jTextPane2.setText(String.valueOf(S));

}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new EjWhile().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
// End of variables declaration//GEN-END:variables

}

segundo ejemplo 23-04

/*
* DoWhile.java
*
* Created on 23 de abril de 2007, 07:25 PM
*/

/**
*
* @author ALUMNO
*/
public class DoWhile_1 extends javax.swing.JFrame {

/** Creates new form DoWhile */
public DoWhile_1() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("x");

jScrollPane1.setViewportView(jTextPane1);

jScrollPane3.setViewportView(jTextPane3);

jLabel3.setText("Raiz");

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

jLabel4.setText("Error");

jScrollPane4.setViewportView(jTextPane4);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel3))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel4)))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jScrollPane4)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE))
.addContainerGap(145, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(168, Short.MAX_VALUE)
.add(jButton1)
.add(163, 163, 163))
.add(layout.createSequentialGroup()
.add(25, 25, 25)
.add(jLabel1)
.add(18, 18, 18)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(278, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(48, 48, 48)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(42, 42, 42)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel4)
.add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(30, 30, 30)
.add(jButton1)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
double xi,x,Fxi,Fx,F1x,E;
int i;

x = Double.parseDouble(jTextPane1.getText());

/// f(x) = x*sin(x) - x*x + 5
// f'(x) = sin(x) + x*cos(x) - 2*x

// x -> xi
// f'(x) = F(x) /( xi - x)
// Xi = x + F(x) / f'(x)

i = 0;
while(i< 10){
Fx = x*Math.sin(x) - x*x + 5;
F1x = Math.sin(x) + x*Math.cos(x) - 2*x;
xi = x + (Fx / F1x);
E = Math.abs(x-xi);
x = xi;
i++;
}
jTextPane3.setText(String.valueOf(xi));
jTextPane4.setText("+- "+String.valueOf(E));
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DoWhile().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
// End of variables declaration//GEN-END:variables

}

serie de taylor

/*
* DoWhile.java
*
* Created on 23 de abril de 2007, 07:25 PM
*/

/**
*
* @author ALUMNO
*/
public class DoWhile extends javax.swing.JFrame {

/** Creates new form DoWhile */
public DoWhile() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("x");

jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setViewportView(jTextPane2);

jLabel2.setText("N");

jScrollPane3.setViewportView(jTextPane3);

jLabel3.setText("Sumatoria");

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

jLabel4.setText("Error");

jScrollPane4.setViewportView(jTextPane4);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(26, 26, 26)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2)))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel3))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel4)))
.add(18, 18, 18)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jScrollPane4)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(121, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(168, Short.MAX_VALUE)
.add(jButton1)
.add(163, 163, 163))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel2)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(33, 33, 33)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel4)
.add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(30, 30, 30)
.add(jButton1)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
double x,Sum,Ti;
int i,n,F;

x = Double.parseDouble(jTextPane1.getText());
n = Integer.parseInt(jTextPane2.getText());

/// s = 1 + x + x*x/2! + .. + pow(x,n)/n!
i = 0;
Ti = 1;
Sum = 1;
do{
i++;
Ti = Ti*(x/i);
Sum = Sum + Ti;
}while(i
jTextPane3.setText(String.valueOf(Sum));
jTextPane4.setText("+- "+String.valueOf(Ti));
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DoWhile().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
// End of variables declaration//GEN-END:variables

}

hallar el tipo de triangulo conociendo sus lados

/*
* Triangulo.java
*
* Created on 23 de abril de 2007, 06:32 PM
*/

/**
*
* @author ALUMNO
*/
public class Triangulo extends javax.swing.JFrame {

/** Creates new form Triangulo */
public Triangulo() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jScrollPane1.setViewportView(jTextPane1);

jLabel1.setText("Lado A");

jLabel2.setText("Lado B");

jScrollPane2.setViewportView(jTextPane2);

jScrollPane3.setViewportView(jTextPane3);

jLabel3.setText("Lado C");

jLabel4.setText("Tipo de Tringulo");

jScrollPane4.setViewportView(jTextPane4);

jButton1.setText("Determina Tipo de Triangulo");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(73, 73, 73)
.add(jLabel4)
.add(24, 24, 24)
.add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 154, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(73, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2))
.add(13, 13, 13))
.add(layout.createSequentialGroup()
.add(jLabel3)
.add(12, 12, 12)))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane3)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 51, Short.MAX_VALUE)
.add(jButton1)
.add(33, 33, 33))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(23, 23, 23)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton1))
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel3)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(39, 39, 39)
.add(jLabel4))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(55, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
double A, B, C;
A = Double.parseDouble(jTextPane1.getText());
B = Double.parseDouble(jTextPane2.getText());
C = Double.parseDouble(jTextPane3.getText());
if((A+B)>C && (B+C)>A && (A+C)>B )
if ((A==B)&&(B==C))
jTextPane4.setText("Triángulo EQUILATERO");
else if((A==B)(B==C)(A==C))
jTextPane4.setText("Triángulo ISOSCELES");
else
jTextPane4.setText("Triángulo ESCALENO");
else
jTextPane4.setText("Triángulo NO EXISTE");
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Triangulo().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
// End of variables declaration//GEN-END:variables

}

clase 2

// hallar las raices de un polinomio aX*X+ b*X +c = 0 insertando como valores a,b,c



/*
* NewJFrame.java
*
* Created on 16 de abril de 2007, 07:19 PM
*/

/**
*
* @author ALUMNO
*/
public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
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();
jScrollPane5 = new javax.swing.JScrollPane();
jTextPane5 = new javax.swing.JTextPane();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("a");

jTextPane1.setName("A");
jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setName("B");
jTextPane2.setName("B");
jScrollPane2.setViewportView(jTextPane2);

jTextPane3.setEditable(false);
jTextPane3.setName("R1");
jScrollPane3.setViewportView(jTextPane3);

jTextPane4.setEditable(false);
jTextPane4.setName("R2");
jScrollPane4.setViewportView(jTextPane4);

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

jLabel2.setText("b");

jLabel3.setText("Raiz 1");

jLabel4.setText("Raiz 2");

jLabel5.setText("c");

jTextPane5.setName("C");
jScrollPane5.setViewportView(jTextPane5);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(306, Short.MAX_VALUE)
.add(jButton1)
.add(120, 120, 120))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(21, 21, 21)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel5)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2)))
.add(14, 14, 14)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jScrollPane5)
.add(jScrollPane2)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel3)
.add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(14, 14, 14)
.add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 196, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(81, 81, 81)
.add(jLabel4)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.add(15, 15, 15)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.add(25, 25, 25)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel5)
.add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel3)
.add(jLabel4))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 17, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane4)
.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
.add(21, 21, 21)
.add(jButton1)
.addContainerGap(49, Short.MAX_VALUE))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:

double a, b, c;
double r1, r2;
String str1,str2;
a = Double.parseDouble(jTextPane1.getText());
b = Double.parseDouble(jTextPane2.getText());
c = Double.parseDouble(jTextPane5.getText());

r1=(-b+Math.sqrt(b*b-4*a*c))/(2*a);
r2=(-b-Math.sqrt(b*b-4*a*c))/(2*a);

str1 = String.valueOf(r1);
str2 = String.valueOf(r2);
jTextPane3.setText(str1);
jTextPane4.setText(str2);
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
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.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
private javax.swing.JTextPane jTextPane5;
// End of variables declaration//GEN-END:variables

}

clase 1

<< PRIMER EJEMPLO >>

// {}
class ejem{
public static void main(String[] arg){
System.out.println("Primer Ejemplo");
}
}

<< GRAFICO 1 >>

import java.awt.*;
import java.applet.*;
public class graf01 extends Applet{
public void paint(Graphics g){
g.drawLine(0,0,100,100);
}
}

<< GRAFICO 2 >>

import java.lang.*;
import java.awt.*;
import java.applet.*;
public class graf02 extends Applet{
public void paint(Graphics g){
Color c1 = new Color( 255, 125, 0 ); // RGB
double x, y,h,Sx,Sy;
int Xp,Yp,Xp1,Yp1; ;
h=0.01;
Sx=10; Sy=50;
g.setColor(c1);
Xp1=0; Yp1=400;
g.drawLine(0,400,800,400);
//g.MoveTo(Xp,Yp);
for (x=0; x<10; x+=h){
y = x*x;
Xp = (int)(x*Sx);
Yp = 400-(int) (y*Sy);
g.drawLine(Xp1,Yp1,Xp,Yp);
Xp1=Xp; Yp1=Yp;
//g.LineTo(Xp,Yp);
//g.MoveTo(Xp,Yp);
}
}
}


<< GRAFICO 3 >>
import java.awt.*;
import java.applet.*;
public class graf03 extends Applet{
public void paint(Graphics g){
Color c1 = new Color( 255, 125, 0 ); // RGB
Color c2 = new Color( 0, 125, 255 ); // RGB
Color c3 = new Color( 255, 125, 32 );
g.setColor(c1);
g.drawLine(0,0,100,100);
g.drawArc(100, 40, 70, 70, 0, 75); // ( x, y, ancho, alto, angi, angf )
g.fillArc(200,10,70, 90, 0, 270);
g.setColor(c2);
g.drawRect(110,110,120,40); // (x, y, ancho, alto)
g.fillRect(10,160,120,40);
g.drawRoundRect(20,200,120,40,20,30); // (x, y, ancho, alto, diamx,diamy)

g.setColor(c2);
}
}