Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package funkcjeztablicami;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Funkcjeztablicami {
  6.  
  7. Scanner wejscie = new Scanner(System.in);
  8.  
  9. static double srednia(double [] t)
  10. {
  11. double suma = 0;
  12. // for(int i =0; i<t.length;++i)
  13. // suma += t[i];
  14. for(double e: t)
  15. suma += e;
  16.  
  17. return suma/t.length;
  18. }
  19.  
  20. public static void main(String[] args) {
  21.  
  22. double rezultat;
  23. double[] t1 = {3, 2, -2, 5, -5, 3};
  24.  
  25. rezultat = srednia(t1);
  26. if(rezultat == 1)
  27. System.out.println("Test 1 pomyślnie zaliczony");
  28. else
  29. System.out.println("Test 1 niezaliczony");
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement