VAT across borders
An online software shop sells to customers in several countries and must add the local sales tax (VAT or GST) to the net price on every invoice. The accounting team needs a tiny tool that shows the tax and the gross price.
- DE 19%, FR 20%, GB 20%, PK 18%, IN 18%, BR 17%
- JP 10%, AE 5%, CH 8.1%
Task: read two lines: the net price (a number with at most 2 decimals) and the 2-letter country code from the list above. The VAT is the net price times the rate, rounded to 2 decimals with halves rounded up (0.125 becomes 0.13). Print exactly one line in the format VAT: 19.00 Gross: 119.00, where Gross is net plus the rounded VAT, always with 2 decimals.
Sample tests
Input
100 DE
Expected output
VAT: 19.00 Gross: 119.00
Input
249.99 GB
Expected output
VAT: 50.00 Gross: 299.99
Your answer is also checked against 4 hidden tests.
Need a hint?
Floats cannot hold 0.125 style halves reliably in every case. The decimal module has an exact rounding mode for halves.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
