Metodo Tridiagonal En C++
Enviado por ChaAngie • 23 de Agosto de 2012 • 994 Palabras (4 Páginas) • 483 Visitas
//Codigo fuente del Metodo Tridiagonal para solucion de ecuaciones.
import javax.swing.JOptionPane;
public class Tridiagonal {
public static void main(String[] args) {
String mensaje = "Instruciones:n" +
" 1.- No introducir caracteres alfabéticos, esto produciría la finalización del programa.n" +
" 2.- No introducir 0 en los indices a, b y c.n";
JOptionPane.showMessageDialog(null, mensaje, "Bienvenido", JOptionPane.INFORMATION_MESSAGE);
String str_n = JOptionPane.showInputDialog("Ingrese n [4 - 10]");
try{
int n = Integer.parseInt(str_n);
if(n<4)
throw new Exception("Mínimo de ecuaciones: 4");
if(n>11)
throw new Exception("Máximo de ecuaciones: 10");
double[][] arr = new double[n][n+1];
String str_cfa = null;
String str_cfb = null;
String str_cfc = null;
String str_cfd = null;
for(int i=0; i<n; i++)
{
if(i>0)
{
str_cfa = JOptionPane.showInputDialog("Ingrese: a" + (i+1));
arr[i][i-1] = Double.parseDouble(str_cfa);
}
str_cfb = JOptionPane.showInputDialog("Ingrese: b" + (i+1));
arr[i][i] = Double.parseDouble(str_cfb);
if(i<n-1){
str_cfc = JOptionPane.showInputDialog("Ingrese: c" + (i+1));
arr[i][i+1] = Double.parseDouble(str_cfc);
...