An employee needs a program to enter the before-tax price of a product and calculate its final price. Assume a value added tax (VAT) of 19%.

Solution

The sales tax can be easily calculated. You must multiply the before-tax price of the product by the sales tax rate. Be careful—the sales tax is not the final price, but only the tax amount.

The after-tax price can be calculated by adding the initial before-tax price and the sales tax that you calculated beforehand.

In this program you can use a constant named VAT for the sales tax rate.

PHP

Java

Notice: Please note that the constant VAT is declared outside of the method main.

C++

Notice: Please note that the constant VAT is declared outside of the function main.

C#

Visual Basic

Notice: Please note that the constant VAT is declared outside of the method Main.

Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!