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