import java.util.Scanner;
public class PJJJeden {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Wprowadź wrtosc A: ");
int A = sc.nextInt();
System.out.println("Wprowadź wrtosc B: ");
int B = sc.nextInt();
System.out.println("Wprowadź wrtosc C: ");
int C = sc.nextInt();
System.out.println(A + "x^2 + " + B + "x + " + C);
double delta = Math.pow(B, 2) - 4 * A * C;
if (delta > 0) {
System.out.println("x1 = " + (-B - Math.sqrt(delta)) / (2 *A) + " x2 = "+ (B - Math.sqrt(delta)) / (2 *A));
}
if (delta == 0){
System.out.println("x1 = " + (B / (2 *A)));
}
if (delta < 0) {
System.out.println("nie ma rozwiazan");
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter