Skip to content

Instantly share code, notes, and snippets.

@kocko
Last active August 7, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kocko/ad50dd42acc50030a2baefa37a3656e3 to your computer and use it in GitHub Desktop.
Save kocko/ad50dd42acc50030a2baefa37a3656e3 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Vyvedete a");
double a = sc.nextDouble();
System.out.println("Vyvedete b");
double b = sc.nextDouble();
System.out.println("Vyvedete c");
double c = sc.nextDouble();
double x1, x2;
double diskriminanta = Math.sqrt(Math.pow(b, 2) - (4 * a * c));
if (diskriminanta < 0) {
System.out.println("Uravnenieto nqma realni koreni we balyk");
} else {
x1 = (-b + diskriminanta) / 2 * a;
x2 = (-b - diskriminanta) / 2 * a;
System.out.println(x1);
System.out.println(x2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment