Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class MojaKlasa
  5. {
  6. public static void main(String []args)
  7. {
  8. float srednia = 0;
  9. if(args.length < 2 || args.length > 10)
  10. {
  11. throw new IllegalArgumentException("Niepoprawna liczba danych!");
  12. }
  13. else
  14. {
  15. try
  16. {
  17. for(int i = 0; i < args.length ; i++)
  18. {
  19. srednia += Float.parseFloat(args[i]);
  20. }
  21.  
  22. srednia = srednia / args.length;
  23.  
  24. System.out.println(srednia);
  25. }
  26. catch(Exception e)
  27. {
  28. throw new IllegalArgumentException("Niepoprawny typ danych!");
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement