Advertisement
blackpab

Java Zestaw 1 - zadanie 6

Mar 25th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package javaz1_6;
  2.  
  3. public class JavaZ1_6 {
  4.  
  5.     public static void main(String[] args) {
  6.         Iloczyn obiekt = new Iloczyn(1, 5, 1);
  7.         System.out.println("Wynik iloczynu: " + obiekt.Oblicz());
  8.     }    
  9. }
  10.  
  11. // --------------------------------------------------------------------
  12.  
  13. package javaz1_6;
  14.  
  15. public class Iloczyn {
  16.     private int a, b;
  17.     private double x;
  18.  
  19.     public int getA() {
  20.         return a;
  21.     }
  22.  
  23.     public void setA(int a) {
  24.         this.a = a;
  25.     }
  26.  
  27.     public int getB() {
  28.         return b;
  29.     }
  30.  
  31.     public void setB(int b) {
  32.         this.b = b;
  33.     }
  34.  
  35.     public double getX() {
  36.         return x;
  37.     }
  38.  
  39.     public void setX(double x) {
  40.         this.x = x;
  41.     }
  42.        
  43.     public double Oblicz() {
  44.         double iloczyn = 1;
  45.         for(int m=this.a; m<=this.b; m++) {
  46.             iloczyn *= Math.sin(m*x);
  47.         }
  48.         return iloczyn;
  49.     }
  50.  
  51.     public Iloczyn(int a, int b, int x) {
  52.         this.a = a;
  53.         this.b = b;
  54.         this.x = x;
  55.     }    
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement