Advertisement
Guest User

FunKwadrat

a guest
Feb 22nd, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Funkcja {
  4.  
  5.     private double a,b,c;
  6.  
  7.     public Funkcja(int a, int b, int c){
  8.         this.a = a;
  9.         this.b = b;
  10.         this.c = c;
  11.     }
  12.  
  13.     public double Zwrot(double x){
  14.  
  15.         return a*(x*x) + b*x + c;
  16.     }
  17.     private double x1,x2;
  18.     public int Licz(){
  19.         double delta = (b*b) - 4 * a * c;
  20.         if(delta > 0){
  21.              x1 = - (Math.sqrt(delta) - b)/ 2*a;
  22.              x2 = - (Math.sqrt(delta) + b)/ 2*a; // maja byc w prywatnych polach, ale nie wiem jak to zrobic
  23.             return 2;
  24.         }
  25.         if(delta == 0) {
  26.             x1 = (-b)/2*a;
  27.             return 1;}
  28.         else return 0;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement