Friday, August 2, 2013

Quadratic

import java.util.*;
public class Quadratic {
   
    public static void main(String[] args) {
       
        Scanner console = new Scanner (System.in);

        double a , b , c , d , r , rr, sq ;

        System.out.println("Please enter the value of a:");
        a = console.nextDouble();

        System.out.println("Please enter the value of b:");
        b = console.nextDouble();

        System.out.println("Please enter the value of c:");
        c = console.nextDouble();

        d = ((b * 2) - 4) * (a * c);
        r = -b / (2 * a);
        rr=(-b+d) / (2*a);
        System.out.println("The Quadratic answer is: " + d);

        if ( d < 0){
        System.out.println("No root available");}

        else if ( d == 0){
        System.out.println("Roots are equal");
        System.out.println("The answer for the roots is: " + r);}

        else if (d > 0){

        System.out.println("The Displayed answer is:" + rr );}

        else
        System.out.println("Invalid");
        System.exit(0);


        }

        }
   

No comments:

Post a Comment