Advertisement
ithoran

PJ Lab 1

Mar 16th, 2016
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. //Funkcija
  2. package prvi;
  3.  
  4. abstract class Funkcija {
  5.     public abstract void nula();
  6.     public abstract double uTojTacki();
  7. }
  8.  
  9. //KvadratniTrinom
  10. package prvi;
  11. import java.util.Scanner;
  12.  
  13. public class KvadratniTrinom extends Funkcija {
  14.     double a, b, c;
  15.    
  16.     public KvadratniTrinom() {
  17.         Scanner unesi = new Scanner(System.in);
  18.         a = unesi.nextDouble();
  19.         b = unesi.nextDouble();
  20.         c = unesi.nextDouble();
  21.         nula();
  22.     }
  23.    
  24.     public void nula(){
  25.         double c = 0;
  26.         int i = 1;
  27.         if ( (a + b) / 2 < a && (a + b) / 2 > b ) {
  28.             System.out.println("Nema resenja!\n");
  29.             return;
  30.         }
  31.         while (a < -b/a && b < -b/2*a) {
  32.             c = (a + b) / Math.pow(2, i);
  33.             i++;
  34.         }
  35.         System.out.printf("%5f", c);
  36.     }
  37.  
  38.     public double uTojTacki() {
  39.         return 0;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement