Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. // OK
  2.     private static void procenat() {   
  3.         Osobe.osobeStream(5000)
  4.             .map(o -> o.getPol() == Pol.MUSKI ? new int[] {(int) o.getDeca().stream().filter(p -> p.getPol() == Pol.MUSKI).count() + 1, (int) o.getDeca().stream().count() + 1}
  5.                     : new int[] {(int) o.getDeca().stream().filter(p -> p.getPol() == Pol.MUSKI).count(), (int) o.getDeca().stream().count() + 1})
  6.             .reduce((x, y) -> new int[] {x[0] + y[0], x[1] + y[1]})
  7.             .map(o -> (double) (o[0] * 100) / o[1])
  8.             .ifPresent(o -> System.out.println("Procenat muskih osoba je " + String.format("%.2f", o)));
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement