Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Hylus on 2017-02-28.
- */
- import java.util.Scanner;
- public class organizacyjne
- {
- public static void main( String[] args)
- {
- System.out.printf("y=ax^2 + bx + c\n");
- System.out.printf("Podaj a b c x1 x2 dx\n"); //x1 i x2 to zakres, dx co ile ma sie zmieniac
- Scanner input = new Scanner (System.in);
- double a = input.nextDouble();
- double b = input.nextDouble();
- double c = input.nextDouble();
- double delta = (b*b)-(4*a*c);
- if (delta>0) {
- double x2;
- double x1;
- x1 = input.nextDouble();
- do {
- x2 = input.nextDouble();
- } while (x2 < x1);
- double dx = input.nextDouble();
- System.out.printf("Reprezentuje funkcje: y=%.2f*x^2+%.2f*b + %.2f\n", a, b, c);
- System.out.printf("Miejsca zerowe to %.2f i %.2f\n", (-b - Math.sqrt(delta)) / (2 * a), (-b + Math.sqrt(delta)) / (2 * a));
- System.out.printf("\tX\t|\tY\n");
- for (double i = x1; i <= x2; i = i + dx) {
- System.out.printf("%.2f\t|\t%.2f\n", i, a * (i * i) + b * i + c);
- }
- }
- else
- {
- System.out.printf("delta < 0");
- }
- }
- }
Advertisement