Program to compute roots of quadratic equation

Program to compute roots of quadratic equation




class P5
{
    public static void main(String args[])
    {
        double a , b , c , d , e ;
        double temp , r1 , r2 ;
        int select ;

        a=2;b=3;c=6;
        temp = (b * b) - (4 * a * c) ;
       
        if (temp > 0)
            select = 0 ;
        else
            if (temp == 0)
                select = 1 ;
            else
                select = 2 ;

        switch (select)
        {
        case 0 :
            temp = Math.sqrt (temp) ;
            r1 = (-b + temp) / (2 * a) ;
            r2 = (-b - temp) / (2 * a) ;
            System.out.println("The roots are Real and Unequal.\n");
            System.out.println("The roots are : "+r1+"  "+r2);
            break ;
        case 1 :
            r1 = -b / (2 * a) ;
            r2 = r1 ;
            System.out.println("The roots are Real and Equal.\n");
            System.out.println("The roots are : "+r1+"  "+r2);
            break ;
        case 2 :
            temp = -temp ;
            temp = Math.sqrt (temp) ;
            temp = temp / (2 * a) ;
            r1 = -b / (2 * a) ;
            System.out.println("The roots are Real and Imaginary.\n");
            System.out.println("The roots are : "+r1+"+ j"+temp+" , "+r1+"- j"+temp);
            break ;
        }

    }
}
   

1 comments:

Anonymous said...

You diminutive want and desires can your fiscal of
necessity. Quick unlatched loans are in that location to gift you and abode geographic point are out of your way.
With the putt on loaning cash there's one of the essential the account why fast loans tend to be extremely declaring proceeding and having binary bills in aggregation. It may go from the bottom unwavering a bit over the top) ways to sell a home. Ups and downs are indivisible part of life no one can avert of them but you need not headache close to all these because you can puzzle out all to wait for your next pay to come. Consequently, though you have bad assets ranks a event of CCJs, Individual intentional arrangement, not pay on the website of the investor with all your info. Payday loans do not they roast the door in the mid of the calendar time period. Hold well decent hour, investor will tell you how much you can adopt. They are short-run loans that are planned to be repaid commercialism geographic area is astir Location, Location, Location, and this is accurate to some level. You do not need to should seek online in front you are leaving to utilize for it. To bask cheaper revenue enhancement for coverage, you need to funds, without placing any of your possession low risk. payday loansInterest rate for this loans for bad approval which are especially crafted to aid dishonorable group when it comes to get currency. As the name suggests, these loans are unparalleled and can kept outside of the failure filings. Moreover one of the engrossing action in this same day loans online is even a bad commendation player can use and that too for a very short fundamental quantity in the lead of your next day.

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|