|
| 1 | +package Secuential.NumberPow; |
| 2 | + |
| 3 | + |
| 4 | +import javax.swing.*; |
| 5 | + |
| 6 | +public class NumberPow { |
| 7 | + |
| 8 | + public double c_x1(double a, double b, double c) { |
| 9 | + double x1, bn, mac, div, raiz1, raiz2, raizf, x1p; |
| 10 | + bn = b * -1; |
| 11 | + mac = Math.pow(b, 2); |
| 12 | + raiz1 = ((-4 * a) * c); |
| 13 | + raiz2 = raiz1 + mac; |
| 14 | + raizf = Math.sqrt(raiz2); |
| 15 | + x1p = bn + raizf; |
| 16 | + div = 2 * a; |
| 17 | + |
| 18 | + x1 = x1p / div; |
| 19 | + return x1; |
| 20 | + } |
| 21 | + |
| 22 | + public double c_x2(double a, double b, double c) { |
| 23 | + double x2, bn, mac, div, raiz1, raiz2, raizf, x1p; |
| 24 | + bn = b * -1; |
| 25 | + mac = Math.pow(b, 2); |
| 26 | + raiz1 = ((-4 * a) * c); |
| 27 | + raiz2 = raiz1 + mac; |
| 28 | + raizf = Math.sqrt(raiz2); |
| 29 | + x1p = bn - raizf; |
| 30 | + div = 2 * a; |
| 31 | + x2 = x1p / div; |
| 32 | + return x2; |
| 33 | + } |
| 34 | + |
| 35 | + public static void main(String args[]) { |
| 36 | + double a, b, c, x1, x2; |
| 37 | + a = Double.valueOf(JOptionPane.showInputDialog("Ingresa el numero a ")); |
| 38 | + b = Double.valueOf(JOptionPane.showInputDialog("Ingresa el numeo b ")); |
| 39 | + c = Double.valueOf(JOptionPane.showInputDialog("Ingresa el numero c ")); |
| 40 | + NumberPow obj = new NumberPow(); |
| 41 | + x1 = obj.c_x1(a, b, c); |
| 42 | + x2 = obj.c_x2(a, b, c); |
| 43 | + JOptionPane.showMessageDialog(null, " x1 es: " + x1); |
| 44 | + JOptionPane.showMessageDialog(null, " x2 es: " + x2); |
| 45 | + } |
| 46 | + |
| 47 | +} |
0 commit comments