1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
var costBeforeTax = Arrays.asList(100, 200, 300, 400, 500);
for (Integer cost : costBeforeTax) { double price = cost + .l2*cost; System.out.println(price);
costBeforeTax.stream() .map((cost) -> cost+.12*costx.forEach(System.out::println); }
double total = 0; for (Integer cost : costBeforeTax) {double price = cost + .12*cost; total = total + price; System.out.println("Total :" + total);
double bill = costBeforeTax.stream() .map((cost) -> cost + .l2*cost) .reduce((sum, cost) ->Isum + cost) .get(); System.out.println("Total : " + bill);
|