Beruflich Dokumente
Kultur Dokumente
java
1 package Ejercicios;
2 import java.text.DecimalFormat;
3 import java.util.Scanner;
4
5 public class GausSeidel {
6
7 public static void main(String[] args) {
8 Scanner leer = new Scanner(System.in);
9 String pregunta,medida = null;
10 double ErrorTotal=0,itera=0;
11 int orden;
12
13 DecimalFormat f = new DecimalFormat("####.######");
14
15 System.out.println("Ingrese la pregunta: ");
16 pregunta = leer.nextLine();
17 System.out.println(" \n");
18
19 System.out.println("Ingrese la cantidad de incognitas: ");
20 orden = leer.nextInt();
21 double Matriz[][] = new double[orden][orden+1];
22 double Vant[] = new double[orden];
23 double Vact[]= new double[orden];
24 String concepto[] = new String[orden];
25
26 System.out.println("**ingresa datos extra***");
27 System.out.print("Ingresa el error: ");
28 double error = leer.nextDouble();
29 System.out.print("ingresa el numero de calculos: ");
30 int calculo= leer.nextInt();
31
32 for (int i = 0; i < orden; i++) {
33 leer.nextLine();
34 System.out.println("ingrese el concepto"+(i+1)+" :");
35 concepto[i]=leer.nextLine();
36 System.out.println("Ingrese valor anterior: ");
37 Vant[i]=leer.nextDouble();
38 Vact[i]=0;
39
40 }
41 leer.nextLine();
42 System.out.print("Ingrese la unidad: ");
43 medida = leer.nextLine();
44
45 //System.out.println("***Capturando matriz***");
46 for (int i = 0; i < orden; i++) {
47 for (int j = 0; j < orden+1; j++) {
48 System.out.println("Ingrese dato en la posicion A[" + (i + 1)+"]["
+(j+1)+ "]");
49 double dato =0;
50 dato= leer.nextDouble();
51 Matriz[i][j]=dato;
52 }
53 }
54
55 System.out.println(String.format("\tInstituto Tecnologico de Culiacán"));
56 System.out.println(String.format(" \tIngenieria en Sistemas Computacionales"));
57 System.out.println();
58 System.out.println("NOMBRE: Oscar Enrique Bojorquez Martinez");
59 System.out.println("MATERIA: Metodos Númericos");
60 System.out.println("MAESTRO: Lopez Velazquez Jacobo Natanael");
61 System.out.println("HORARIO: 11:00-12:00");
Page 1
GausSeidel.java
Page 2
GausSeidel.java
121 }
122 }else {
123 if(itera<calculo) {
124
125 } else {
126 System.out.println("_______________________________________________________
_____________________________________________________________________");
127 System.out.println("Resultados: ");
128 System.out.println("Lo siento, no se encontro un resultado apropiado en los
calculos permitidos.");
129
130 }
131 }
132
133 }while(ErrorTotal>error || calculo<=itera);
134
135
136 }
137
138
139
140
141
142
143
144
145 }
146
147
148
149
150
151
Page 3