You are on page 1of 9

mat[0][0]=array[0];

mat[1][0]=array[1];

mat[2][0]=array[2];

auxa=mat[0][0]*mat[1][1]*mat[2][2]+mat[1][0]*mat[2][1]*mat[0][2]+mat[2][0]*mat[0][1]*mat[1][2];

auxb=mat[0][2]*mat[1][1]*mat[2][0]+mat[1][2]*mat[2][1]*mat[0][0]+mat[2][2]*mat[0][1]*mat[1][0];

dx=auxa-auxb;

mat[0][0]=n1;

mat[1][0]=n2;

mat[2][0]=n3;

System.out.println(": "+dx);

return dx;

public int hdy(int mat[][], int array[]){

int dy=0, auxa=0 , auxb=0 ;

int n1 , n2 , n3 ;

n1=mat[0][1];

n2=mat[1][1];

n3=mat[2][1];

mat[0][1]=array[0];

mat[1][1]=array[1];

mat[2][1]=array[2];

auxa=mat[0][0]*mat[1][1]*mat[2][2]+mat[1][0]*mat[2][1]*mat[0][2]+mat[2][0]*mat[0][1]*mat[1][2];

auxb=mat[0][2]*mat[1][1]*mat[2][0]+mat[1][2]*mat[2][1]*mat[0][0]+mat[2][2]*mat[0][1]*mat[1][0];
dy=(auxa-auxb);

mat[0][1]=n1;

mat[1][1]=n2;

mat[2][1]=n3;

System.out.println(": "+dy);

return dy;

public int hdz(int mat[][], int array[]){

int dz=0, auxa=0 , auxb=0 ;

int n1 , n2 , n3 ;

n1=mat[0][2];

n2=mat[1][2];

n3=mat[2][2];

mat[0][2]=array[0];

mat[1][2]=array[1];

mat[2][2]=array[2];

auxa=mat[0][0]*mat[1][1]*mat[2][2]+mat[1][0]*mat[2][1]*mat[0][2]+mat[2][0]*mat[0][1]*mat[1][2];

auxb=mat[0][2]*mat[1][1]*mat[2][0]+mat[1][2]*mat[2][1]*mat[0][0]+mat[2][2]*mat[0][1]*mat[1][0];

dz=auxa-auxb;

mat[0][2]=n1;

mat[1][2]=n2;

mat[2][2]=n3;

System.out.println(": "+dz);
return dz;

public void rf(double det , double dx , double dy , double dz){

System.out.println("Valor de x: "+(dx/det));

System.out.println("Valor de y: "+(dy/det));

System.out.println("Valor de z: "+(dz/det));

package javaapplication5;

public class Principal3 {

public static void main(String[] args) {

Problema3 ob1 = new Problema3();

int x1 = 0 , y1 = 0, z1 = 0;

int y2 = 0 , z2 = 0;

int z3 = 0;

double det=0 , dx=0 , dy=0 , dz=0 ;

x1=ob1.lx1(x1);

y1=ob1.ly1(y1);

z1=ob1.lz1(z1);

y2=ob1.ly2(y2);

z2=ob1.lz2(z2);

z3= ob1.lz3(z3);

ob1.a1();

ob1.a2();

ob1.a3();

System.out.println("---->Imprimiremos El sistema de Ecuaciones------------<");


System.out.println("");

ob1.sistema(x1,y1, z1,y2,z2, z3);

int[][] mat = new int[3][3];

ob1.llenado(mat, x1, y1, z1, y2, z2, z3);

System.out.println("Determinante de la matriz principal : ");

det=ob1.det(x1, y2, z3);

int [] array = new int[3];

ob1.arr(array);

System.out.println("\nDeterminante de la variable'x' : ");

dx=ob1.hdx(mat, array);

System.out.println("Determinante de la variable'y' : ");

dy=ob1.hdy(mat, array);

System.out.println("Determinante de la variable'z' : ");

dz=ob1.hdz(mat, array);

System.out.println("---<<Hallando resultados finales>>---");

ob1.rf(det, dx, dy, dz);

Compilación
run:

Ingrese coef.variable X

Ingrese coef.variable Y

6
Ingrese coef.variable Z

Ingrese coef.variable Y

Ingrese coef.variable Z

Ingrese coef.variable Z

---->Imprimiremos El sistema de Ecuaciones------------<

5X + 6Y + 4Z = 1

1Y + 9Z = 6

5Z = 8

Determinante de la matriz principal :

: 25

Determinante de la variable'x' :

: 225

Determinante de la variable'y' :

: -210

Determinante de la variable'z' :

: 40

---<<Hallando resultados finales>>---

Valor de x: 9.0

Valor de y: -8.4

Valor de z: 1.6

BUILD SUCCESSFUL (total time: 11 seconds)

Problema 4
package javaapplication5;
import java.util.Scanner;

public class Problema4 {

Scanner sc = new Scanner(System.in);

public void nombres(String array[]){

System.out.println("Ingrese los nombres de los alumnos: ");

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

array[i]=sc.nextLine();

public void notas(String arrnot1[]){

System.out.println("Ingrese las notas de los alumnos: ");

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

arrnot1[i]=sc.nextLine();

public void pasar(String array[] , String arrnot1[] , String matriz[][]){

matriz[0][0]=array[0];

matriz[1][0]=array[1];

matriz[2][0]=array[2];

matriz[3][0]=array[3];

matriz[0][1]=" 10.2 ";//Conversion de Decimal a String

matriz[1][1]="11.4";//Conversion de Decimal a String

matriz[2][1]="12.8";//Conversion de Decimal a String

matriz[3][1]="14.6";//Conversion de Decimal a String


}

public void mostrar1(String matriz[][]){

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

for(int j=0;j<2;j++){

System.out.print(" "+matriz[i][j]);

}System.out.println("");

public void ordenar(String matriz[][]){

System.out.print(matriz[3][0]+" : "+matriz[3][1]);

System.out.println("");

System.out.print(matriz[2][0]+" : "+matriz[2][1]);

System.out.println("");

System.out.print(matriz[1][0]+" : "+matriz[1][1]);

System.out.println("");

System.out.print(matriz[0][0]+" : "+matriz[0][1]);

System.out.println("");

package javaapplication5;

public class Principal4 {

public static void main(String[] args) {

Problema4 ob1 = new Problema4();

String [] array = new String[4];


String [] arrnot1 = new String[4];

double [] arrnot2=new double[4];

String [][] matriz = new String[4][4];

ob1.nombres(array);

ob1.pasar(array, arrnot1, matriz);

System.out.println("----->Las notas con nombres son : ");

ob1.mostrar1(matriz);

System.out.println("------>Notas ordenadas son : ");

ob1.ordenar(matriz);

Compilación
run:

Ingrese los nombres de los alumnos:

jairo

luis

abel

juan

----->Las notas con nombres son :

jairo 10.2

luis 11.4

abel 12.8

juan 14.6

------>Notas ordenadas son :

juan : 14.6
abel : 12.8

luis : 11.4

jairo : 10.2

BUILD SUCCESSFUL (total time: 10 seconds)

You might also like