Advertisement
deyanmalinov

4. Add VAT - 2

Apr 11th, 2020
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3. import java.util.function.UnaryOperator;
  4.  
  5. public class Main {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         String[] line = scan.nextLine().split(", ");
  9.         UnaryOperator<Double> addVat = d -> 1.2 * d;
  10.         System.out.println("Prices with VAT:");
  11.         Arrays.stream(line).map(Double::parseDouble)
  12.                 .map(addVat)
  13.                 .forEach(num -> System.out.printf("%.2f\n", num));
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement