Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class ExerciseFive {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String inputOne = scanner.nextLine();
- double a = Double.parseDouble(inputOne);
- String inputTwo = scanner.nextLine();
- double b = Double.parseDouble(inputTwo);
- String inputThree = scanner.nextLine();
- double c = Double.parseDouble(inputThree);
- double d = b * b - 4 * a * c;
- double x1 = (-b - Math.sqrt(d)) / (2 * a);
- double x2 = (-b + Math.sqrt(d)) / (2 * a);
- DecimalFormat format = new DecimalFormat("0.#");
- System.out.println("x1 = " + format.format(x1) + "; x2 = " + format.format(x2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment