Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dzielenie.bezpieczne;
- import static java.lang.Math.sqrt;
- import java.util.Scanner;
- public class DzielenieBezpieczne {
- public static void main(String[] args) {
- double a, b, c, delta, x1, x2, x0;
- Scanner sc = new Scanner(System.in);
- System.out.println("Funkcja kwadratowa ");
- System.out.println("Ax^2 + Bx + C");
- System.out.println("Wprowadź A");
- a = sc.nextDouble();
- if (a==0)
- System.out.println("To funkcja liniowa...");
- else {
- System.out.println("Wprowadź B ");
- b = sc.nextDouble();
- System.out.println("Wprowadź C");
- c = sc.nextDouble();
- delta = (b*b)-(4*(a*c));
- if (delta < 0) {
- System.out.println("Równanie nie ma rozwiązań...");
- System.out.println("Delta = " +delta);}
- else {
- if (delta ==0){
- x0 = (-(b))/( 2 * a );
- System.out.println("Delta = " +delta);
- System.out.println("X0 = " +x0);
- }
- else {
- x1 = (-(b)- sqrt(delta))/( 2 * a );
- x2 = (-(b)+ sqrt(delta))/( 2 * a );
- System.out.println("Delta = " +delta);
- System.out.println("X1 = " +x1);
- System.out.println("X2 = " +x2);
- }
- }}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement