Advertisement
Didart

Add VAT

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