130k views
5 votes
Please help show how to program using JAVA thank you!

Please help show how to program using JAVA thank you!-example-1

1 Answer

7 votes

Answer:

import java.util.Scanner;

public class QuadraticEquation {

public static void main(String[] args) {;

Scanner sc = new Scanner(System.in);

double a, b, c, x1, x2, delta;

System.out.print("Enter the value of A: ");

a = sc.nextDouble();

System.out.print("Enter the value of B: ");

b = sc.nextDouble();

System.out.print("Enter the value of C: ");

c = sc.nextDouble();

delta = Math.pow(b, 2) - (4 * a * c);

x1 = (-b + Math.sqrt(delta)) / (2 * a);

x2 = (-b - Math.sqrt(delta)) / (2 * a);

System.out.println("");

System.out.println("The value of X1 is: " + x1);

System.out.println("The value of X2 is: " + x2);

}

}

Step-by-step explanation:

if you're getting errors, try using comma instead of dot when typing the entries. But only if you get error (you probably won't). The empty system.out.println is just to skip one line so the results don't display to close to the inputs.

User Vitall
by
8.4k points