Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package dzielenie.bezpieczne;
  2.  
  3. import static java.lang.Math.sqrt;
  4. import java.util.Scanner;
  5.  
  6. public class DzielenieBezpieczne {
  7.  
  8.  
  9. public static void main(String[] args) {
  10.  
  11. double a, b, c, delta, x1, x2, x0;
  12. Scanner sc = new Scanner(System.in);
  13. System.out.println("Funkcja kwadratowa ");
  14. System.out.println("Ax^2 + Bx + C");
  15. System.out.println("Wprowadź A");
  16.  
  17. a = sc.nextDouble();
  18.  
  19. if (a==0)
  20. System.out.println("To funkcja liniowa...");
  21. else {
  22. System.out.println("Wprowadź B ");
  23. b = sc.nextDouble();
  24. System.out.println("Wprowadź C");
  25. c = sc.nextDouble();
  26.  
  27. delta = (b*b)-(4*(a*c));
  28.  
  29. if (delta < 0)
  30. System.out.println("Równanie nie ma rozwiązań...");
  31. else {
  32. if (delta ==0){
  33. x0 = (-(b))/( 2 * a );
  34. System.out.println("Delta = " +delta);
  35. System.out.println("X0 = " +x0);
  36. }
  37.  
  38. else {
  39. x1 = (-(b)- sqrt(delta))/( 2 * a );
  40. x2 = (-(b)+ sqrt(delta))/( 2 * a );
  41. System.out.println("Delta = " +delta);
  42. System.out.println("X1 = " +x1);
  43. System.out.println("X2 = " +x2);
  44. }
  45. }}
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement