Sunteți pe pagina 1din 5

TECNOLÓGICO NACIONAL DE MEXICO

INSTITUTO TECNOLÓGICO DE TAPACHULA

DOCUMENTACIÓN DEL PROGRAMA


“METODO DE DETERMINANTES POR LA REGLA DE CRAMER”
MÉTODOS NUMÉRICOS

ING. SISTEMAS COMPUTACIONALES.


4ºB

CHRISTIAN JAIME GARCIA AQUINO


CASSANDRA ISABEL JOVEL IBARRA
ARECIO MARCELO PEREZ GARCIA

MCC. TERESA DEL CARMEN CABRERA GÓMEZ.

MARTES 24 DE ABRIL DEL 2018


DESARROLLO DE LA PRACTICA

En el programa de método de determinantes se realiza toda la programación


dentro de una sola clase el cual declaramos nuestras variables a utilizar:

Variables dentro del código:

int MD0[][]= new int [5][4];


int MD1[][]= new int [5][4];
int MD2[][]= new int [5][4];
int MD3[][]= new int [5][4];
int D0,D1,D2,D3;
float x,y,z;

Variables del JFrame


private javax.swing.JButton Calcular;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JLabel lblD0;
private javax.swing.JLabel lblD1;
private javax.swing.JLabel lblD2;
private javax.swing.JLabel lblD3;
private javax.swing.JLabel lblX;
private javax.swing.JLabel lblY;
private javax.swing.JLabel lblZ;
private javax.swing.JTable tblD1;
private javax.swing.JTable tblD2;
private javax.swing.JTable tblD3;
private javax.swing.JTextField txt11;
private javax.swing.JTextField txt12;
private javax.swing.JTextField txt13;
private javax.swing.JTextField txt14;
private javax.swing.JTextField txt21;
private javax.swing.JTextField txt22;
private javax.swing.JTextField txt23;
private javax.swing.JTextField txt24;
private javax.swing.JTextField txt31;
private javax.swing.JTextField txt32;
private javax.swing.JTextField txt33;
private javax.swing.JTextField txt34;

Como el proyecto esta hecho en un JFrame se inicializan los componentes a


utilizar con este constructor

public Determinantes_Kramer() {
initComponents();
}

Para obtener todos los determinantes se tiene un solo Método el cual es

private void CalcularActionPerformed(java.awt.event.ActionEvent evt)

Aquí el código
private void CalcularActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
DefaultTableModel Modelo=(DefaultTableModel) tblD1.getModel();
DefaultTableModel Modelo2=(DefaultTableModel) tblD2.getModel();
DefaultTableModel Modelo3=(DefaultTableModel) tblD3.getModel();
//Obtenemos todos los valores numericos de las cajas de texto y las
guardamos en la matriz
MD0[0][0]=Integer.parseInt(txt11.getText());
MD0[0][1]=Integer.parseInt(txt12.getText());
MD0[0][2]=Integer.parseInt(txt13.getText());
MD0[0][3]=Integer.parseInt(txt14.getText());//Excluye
MD0[1][0]=Integer.parseInt(txt21.getText());
MD0[1][1]=Integer.parseInt(txt22.getText());
MD0[1][2]=Integer.parseInt(txt23.getText());
MD0[1][3]=Integer.parseInt(txt24.getText());//Excluye
MD0[2][0]=Integer.parseInt(txt31.getText());
MD0[2][1]=Integer.parseInt(txt32.getText());
MD0[2][2]=Integer.parseInt(txt33.getText());
MD0[2][3]=Integer.parseInt(txt34.getText());//Excluye
MD0[3][0]=Integer.parseInt(txt11.getText());
MD0[3][1]=Integer.parseInt(txt12.getText());
MD0[3][2]=Integer.parseInt(txt13.getText());
MD0[3][3]=Integer.parseInt(txt14.getText());//Excluye
MD0[4][0]=Integer.parseInt(txt21.getText());
MD0[4][1]=Integer.parseInt(txt22.getText());
MD0[4][2]=Integer.parseInt(txt23.getText());
MD0[4][3]=Integer.parseInt(txt24.getText());//Excluye
//Rellenado Tabla D1
for(int j=0;j<=4;j++)
{
for(int k=1;k<=2;k++)
{
tblD1.setValueAt(MD0[j][k], j, k);
MD1[j][k]=MD0[j][k];

}
}
for(int l=0;l<=4;l++)
{
tblD1.setValueAt(MD0[l][3], l, 0);
MD1[l][0]=MD0[l][3];
}
//Termina Rellenado Tabla D1

//Rellenado Tabla D2
for(int j=0;j<=4;j++)
{
for(int k=0;k<=2;k=k+2)
{
tblD2.setValueAt(MD0[j][k], j, k);
MD2[j][k]=MD0[j][k];
}
}
for(int l=0;l<=4;l++)
{
tblD2.setValueAt(MD0[l][3], l, 1);
MD2[l][1]=MD0[l][3];
}
//Termina Rellenado Tabla D2

//Rellenado Tabla D3
for(int j=0;j<=4;j++)
{
for(int k=0;k<=1;k++)
{
tblD3.setValueAt(MD0[j][k], j, k);
MD3[j][k]=MD0[j][k];
}
}
for(int l=0;l<=4;l++)
{
tblD3.setValueAt(MD0[l][3], l, 2);
MD3[l][2]=MD0[l][3];
}
//Termina Rellenado Tabla D3
//Calculo de determinantes
//D0

D0=(((MD0[0][0]*MD0[1][1]*MD0[2][2])+(MD0[1][0]*MD0[2][1]*MD0[3][2])+(MD0[
2][0]*MD0[3][1]*MD0[4][2]))-
((MD0[0][2]*MD0[1][1]*MD0[2][0])+(MD0[1][2]*MD0[2][1]*MD0[3][0])+(MD0[2][2]
*MD0[3][1]*MD0[4][0])));
lblD0.setText(String.valueOf(D0));
//Fin D0
//D1

D1=(((MD1[0][0]*MD1[1][1]*MD1[2][2])+(MD1[1][0]*MD1[2][1]*MD1[3][2])+(MD1[
2][0]*MD1[3][1]*MD1[4][2]))-
((MD1[0][2]*MD1[1][1]*MD1[2][0])+(MD1[1][2]*MD1[2][1]*MD1[3][0])+(MD1[2][2]
*MD1[3][1]*MD1[4][0])));
lblD1.setText(String.valueOf(D1));
x=D1/D0;
lblX.setText(String.valueOf(x));
//Fin D1
//D2

D2=(((MD2[0][0]*MD2[1][1]*MD2[2][2])+(MD2[1][0]*MD2[2][1]*MD2[3][2])+(MD2[
2][0]*MD2[3][1]*MD2[4][2]))-
((MD2[0][2]*MD2[1][1]*MD2[2][0])+(MD2[1][2]*MD2[2][1]*MD2[3][0])+(MD2[2][2]
*MD2[3][1]*MD2[4][0])));
lblD2.setText(String.valueOf(D2));
y=D2/D0;
lblY.setText(String.valueOf(y));
//Fin D2
//D3

D3=(((MD3[0][0]*MD3[1][1]*MD3[2][2])+(MD3[1][0]*MD3[2][1]*MD3[3][2])+(MD3[
2][0]*MD3[3][1]*MD3[4][2]))-
((MD3[0][2]*MD3[1][1]*MD3[2][0])+(MD3[1][2]*MD3[2][1]*MD3[3][0])+(MD3[2][2]
*MD3[3][1]*MD3[4][0])));
lblD3.setText(String.valueOf(D3));
z=D3/D0;
lblZ.setText(String.valueOf(z));
//Fin D3
}