Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class QuadraticEquation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double a = scanner.nextInt();
- double b = scanner.nextInt();
- double c = scanner.nextInt();
- double d = b * b - 4 * a * c;
- double x1 = (- b - Math.sqrt(d)) / (2 * a);
- double x2 = (- b + Math.sqrt(d)) / (2 * a);
- if (x1 == (int)x1) {
- System.out.print("x1=" + (int)x1 + ";");
- }else System.out.print("x1=" + x1 + ";");
- if (x2 == (int)x2) {
- System.out.print("x2=" + (int)x2 + ";");
- }else System.out.print("x2=" + x2 + ";");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement