Advertisement
blackpab

zad javaAA

Feb 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package zestaw;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  *
  12.  * @author student
  13.  */
  14. public class Sumator {
  15.  
  16.     private int N;
  17.     private double suma;
  18.  
  19.     public void sumuj() {
  20.         suma = 0;
  21.         for (int m = 1; m <= N; m++) {
  22.             suma = suma + 1 / Math.pow(2, m);
  23.         }
  24.     }
  25.  
  26.     double wypisz() {
  27.         return suma;
  28.     }
  29.  
  30.     public Sumator(int N) {
  31.         this.N = N;
  32.         suma = Double.NaN;
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement