All pastes #2063932 Raw Edit

Miscellany

public text v1 · immutable
#2063932 ·published 2011-05-18 22:07 UTC
rendered paste body
    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package question2;
import javax.swing.JOptionPane;
import java.math.*;
import java.lang.*;
/**
 *
 * @author crusoe
 */
public class Question2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        String      numA, numB, numC;
        double         a, b, c, x1, x2;
        
        numA = JOptionPane.showInputDialog("Enter a double for A");
        numB = JOptionPane.showInputDialog("Enter a double for B");
        numC = JOptionPane.showInputDialog("Enter and double for C");
        
        a = Double.parseDouble (numA);
        b = Double.parseDouble (numB);
        c = Double.parseDouble (numC);
        
        x1 = ((- b) + (Math.sqrt(Math.pow(b, 2) - (4*a*c))) / (2*a));
        x2 = ((- b) - (Math.sqrt(Math.pow(b, 2) - (4*a*c))) / (2*a));
        
        JOptionPane.showMessageDialog(null, "The value of x1 is" + x1 + "and the value of x2 is " + x2);
    }
}