Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Create a java program to solve quadratic eqations

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Create a java program to solve quadratic eqations

    Solving a quadratic equation The program must have two methods quadraticEquationRoot1 which takes as input 3 doubles, representing a,b,c and returns the larger of the two roots and quadraticEquationRoot 2 which takes as input 3 doubles, representing a,b, and c (in that order) and returns the smaller of the two roots.

    We assume that the numbers a,b,c are chosen so that the square root is never the square root of a negative number

    I have the following written down so far. I am not sure on how to introduce the second method

    public static void main(string args[]){

    }

    public static double quadraticEquationRoot1(int a, int b, int c) (){

    }

    if(Math.sqrt(Math.pow(b, 2) - 4*a*c) == 0)

    {

    return -b/(2*a);

    }else

    {

    int root1, root2;

    root1 = (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);

    root2 = (-b - Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);

    return Math.max(root1, root2);
    }

    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Create a java program to solve quadratic eqations

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/75067-solving-quadratic-equation-using-java.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


Similar Threads

  1. HELP ME TO SOLVE THIS JAVA FOR LOOP PROGRAM
    By muhammad waqar in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 22nd, 2012, 03:17 PM
  2. How to solve “NullPointerException” in my Java Program ?
    By unknowny in forum Java Theory & Questions
    Replies: 8
    Last Post: July 24th, 2012, 04:06 PM
  3. how I can solve this program ?
    By Noni in forum Object Oriented Programming
    Replies: 9
    Last Post: January 20th, 2011, 05:33 PM
  4. Help with Quadratic forumla equation in java please.
    By taylor6132 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 27th, 2010, 07:27 PM
  5. help!! quadratic program
    By dscrudato21xo in forum What's Wrong With My Code?
    Replies: 14
    Last Post: October 18th, 2009, 05:13 PM

Tags for this Thread