Baskara
import java.util.Scanner;
import java.util.InputMismatchException;
 
public class baskara
{
    public static void main(String [] args) {
        //code
        Scanner sc = new Scanner(System.in);
        System.out.println("digite o termo a");
        int a = sc.nextInt();
        Scanner sc1 = new Scanner(System.in);
        System.out.println("digite o termo b");
        int b = sc1.nextInt();
        Scanner sc2 = new Scanner(System.in);
        System.out.println("digite o termo c");
        int c = sc2.nextInt();
        double delta = (Math.pow(b,2) - 4*a*c);
        System.out.println(delta);
        if (delta < 0) { 
            System.out.println("não há raiz real");
        }
        else {
            System.out.println("*****************");
            System.out.print("delta = ");
            System.out.println(delta);
            double x1 = (-b + Math.sqrt(delta))/2*a;
            System.out.print("x1 = ");
            System.out.println(x1);
            double x2 = (-b - Math.sqrt(delta))/2*a;
            System.out.print("x2 = ");
            System.out.println(x2);
            System.out.println("*****************");        
    }        
    }
}

voltar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.