Results 1 to 5 of 5
  1. #1
    bestlita is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default Write a java program to display a gui of quadratic equation

    package Almigthy;
    import javax.swing.*;
    /**
    *
    * @author YUSBETH
    */
    public class quadraticEquation {
    private static Object String;
    private static String txt;
    public static void main(String[]args ){
    String = null;
    int a, b, c;
    txt =JOptionPane.showInputDialog("Enter a");
    a=Integer.parseInt(txt);
    txt =JOptionPane.showInputDialog("Enter b");
    b=Integer.parseInt(txt);
    txt =JOptionPane.showInputDialog("Enter c");
    c=Integer.parseInt(txt);
    double D=descriminant(a,b,c);
    if (D<0){
    System.out.println("Complex Roots");
    }
    else if(D==0){
    double X1=(-b)/(2*a);
    double X2=X1;
    System.out.println("Equal Roots" + X1);
    }
    else{
    double X1=((-b)+ Math.sqrt(D))/(2*a);
    double X2=((-b)- Math.sqrt(D))/(2*a);
    System.out.println("Roots" + X1 + "and " + X2);
    }
    }
    public static double descriminant(int a, int b, int c){
    double Quad=(b*b)-(4*a*c);
    return Quad;
    }
    }

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    Do you have a question associated with this? (and please use the code tags)

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    [code]
    YOUR CODE HERE
    [/code]

    Is how you use code tags.

  4. #4
    bestlita is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    sorry, i did understand your question, (sunde887) , (dowhile)

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What don't you understand? doWhile was asking what is your specific question, as it stands now, this is simply a code dump. Provide an exact question for us to help you with. He also suggested you use code tags when posting code. My post shows how they are used.

Similar Threads

  1. Quadratic Equation Code Question
    By meangrant in forum New To Java
    Replies: 5
    Last Post: 10-31-2010, 03:22 AM
  2. quadratic equation, problems that i can't solve
    By kourai in forum New To Java
    Replies: 2
    Last Post: 10-14-2010, 01:31 PM
  3. quadratic equation whith Rational class
    By adamrain in forum New To Java
    Replies: 8
    Last Post: 12-22-2009, 05:35 PM
  4. Quadratic Equation
    By jpnym15 in forum New To Java
    Replies: 4
    Last Post: 11-12-2008, 03:29 AM
  5. Help with quadratic equation in java
    By paul in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •