Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static java.lang.Math.*;
- // one class needs to have a main() method
- public class HelloWorld
- {
- // arguments are passed using the text field below this editor
- public static void main(String[] args) {
- int a = 1;
- int b = 3;
- int c = -4;
- int delta = b*b-4*a*c;
- System.out.println(sqrt(delta));
- double pierwiastek_1 = (-b+(sqrt(delta)))/2*a;
- double pierwiastek_2 = (-b-(sqrt(delta)))/2*a;
- double pierwiastek_sam = -b/2*a;
- if (delta<0)
- System.err.println("Równanie kwadratowe nie ma pierwiastków");
- else if (delta==0)
- System.out.println("Równanie ma tylko jeden pierwiastek: " + pierwiastek_sam);
- else
- System.out.println("Pierwiastkami tego równania kwadratowego są: " + pierwiastek_1 + " oraz " + pierwiastek_2);
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement