Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Scanner s = new Scanner (System.in);
  2.  
  3. System.out.print("Limit: ");
  4.  
  5.  
  6. int n = s.nextInt();
  7. double x1, x2;
  8. for (int a = 1; a <= n; a++) {
  9. for (int b = 1; b <= n; b++) {
  10. for (int c = 1; c <= n; c++) {
  11. System.out.println("a = " + a + " b = " + b + " c = " + c);
  12.  
  13. double d = b*b - 4*a*c;
  14. if (d<0) {
  15. System.out.println("No solution");
  16. }
  17. else if (d == 0) {
  18. x1 = -b/(2*a);
  19. System.out.printf ("x1 = %f\n", x1);
  20. }
  21. else if (d>0) {
  22. x1 = (-b - Math.sqrt(d) )/ (2*a);
  23. x2 = (-b + Math.sqrt(d))/(2*a);
  24. System.out.printf("x1 = %f\n", x1);
  25. System.out.printf ("x2 = %f\n", x2);
  26. }
  27.  
  28.  
  29. }
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement