/*
* To change this template, choose Tools Templates
* and open the template in the editor.
*/
package pruebajava;
import javax.swing.*;
/**
*
* @author CENTIC
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JOptionPane.showMessageDialog(null,
"PROGRAMA PARA HALLAR LAS RAICES DE UNA ECUACIÓN CUADRATICA",
"SALIDA GRAFICA",
JOptionPane.INFORMATION_MESSAGE);
final double TOL= 1E-15;
// Constante (utilice ‘final’)
String entrada= JOptionPane.showInputDialog("Introduzca a");
double a= Double.parseDouble(entrada);
entrada= JOptionPane.showInputDialog("Introduzca b");
double b= Double.parseDouble(entrada);
entrada= JOptionPane.showInputDialog("Introduzca c");
double c= Double.parseDouble(entrada);
double discriminante= b*b - 4.0*a*c;
if ( discriminante < 0)
JOptionPane.showMessageDialog(null,
"Lo siento, la raíz no es un número real",
"SALIDA: NO HAY RAICES",
JOptionPane.INFORMATION_MESSAGE);
else if (Math.abs(discriminante) <= TOL) {
double raiz= -0.5 * b / a;
JOptionPane.showMessageDialog(null,
"La raíz es" + raiz,
"SALIDA: NO HAY RAICES",
JOptionPane.INFORMATION_MESSAGE);
}
else { // Redefinir ‘raíz’; los bloques tienen sus propios ámbitos
double raiz=(-b + Math.sqrt(discriminante))/ (2.0*a);
double raiz2=(-b- Math.sqrt(discriminante))/ (2.0*a);
// System.out.println("Raíces:" + raiz + " y " + raiz2);
JOptionPane.showMessageDialog(null,
"Raíces:" + raiz + " y " + raiz2,
"Valores de las raices",
JOptionPane.INFORMATION_MESSAGE);
}
System.exit(0);
// TODO code application logic here
}
}
* To change this template, choose Tools Templates
* and open the template in the editor.
*/
package pruebajava;
import javax.swing.*;
/**
*
* @author CENTIC
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JOptionPane.showMessageDialog(null,
"PROGRAMA PARA HALLAR LAS RAICES DE UNA ECUACIÓN CUADRATICA",
"SALIDA GRAFICA",
JOptionPane.INFORMATION_MESSAGE);
final double TOL= 1E-15;
// Constante (utilice ‘final’)
String entrada= JOptionPane.showInputDialog("Introduzca a");
double a= Double.parseDouble(entrada);
entrada= JOptionPane.showInputDialog("Introduzca b");
double b= Double.parseDouble(entrada);
entrada= JOptionPane.showInputDialog("Introduzca c");
double c= Double.parseDouble(entrada);
double discriminante= b*b - 4.0*a*c;
if ( discriminante < 0)
JOptionPane.showMessageDialog(null,
"Lo siento, la raíz no es un número real",
"SALIDA: NO HAY RAICES",
JOptionPane.INFORMATION_MESSAGE);
else if (Math.abs(discriminante) <= TOL) {
double raiz= -0.5 * b / a;
JOptionPane.showMessageDialog(null,
"La raíz es" + raiz,
"SALIDA: NO HAY RAICES",
JOptionPane.INFORMATION_MESSAGE);
}
else { // Redefinir ‘raíz’; los bloques tienen sus propios ámbitos
double raiz=(-b + Math.sqrt(discriminante))/ (2.0*a);
double raiz2=(-b- Math.sqrt(discriminante))/ (2.0*a);
// System.out.println("Raíces:" + raiz + " y " + raiz2);
JOptionPane.showMessageDialog(null,
"Raíces:" + raiz + " y " + raiz2,
"Valores de las raices",
JOptionPane.INFORMATION_MESSAGE);
}
System.exit(0);
// TODO code application logic here
}
}
Suscribirse a:
Enviar comentarios (Atom)
Publicar un comentario