Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner s = new Scanner (System.in);
- System.out.print("Limit: ");
- int n = s.nextInt();
- double x1, x2;
- for (int a = 1; a <= n; a++) {
- for (int b = 1; b <= n; b++) {
- for (int c = 1; c <= n; c++) {
- System.out.println("a = " + a + " b = " + b + " c = " + c);
- double d = b*b - 4*a*c;
- if (d<0) {
- System.out.println("No solution");
- }
- else if (d == 0) {
- x1 = -b/(2*a);
- System.out.printf ("x1 = %f\n", x1);
- }
- else if (d>0) {
- x1 = (-b - Math.sqrt(d) )/ (2*a);
- x2 = (-b + Math.sqrt(d))/(2*a);
- System.out.printf("x1 = %f\n", x1);
- System.out.printf ("x2 = %f\n", x2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement