Beginners Programs :

Java: VAT Calculator Program In 2 Ways | Java Programs

Java program to calculate VAT, Value-Added Tax. VAT is tax that is levied on the consumer when he/she buys the product or service.

VAT is multi stage tax and something which is levied on each stage of production. Although the tax is levied upon the producers or the businesses (for easy understanding) it is the consumer or end user who actually ends up paying it.

What the businesses do in order to escape the burden this tax is to account it in the cost of the product. In this way they can afford to pay taxes to the government without actually having to pay anything out of their pockets. Any person who is earning money by transacting on goods or services north of rs 500000 is supposed to register under VAT.

The rates of VAT differs according to the province and particularly in India the states were supposed to collect VAT.

Calculation of VAT

VAT is calculated by deducting input tax from output tax. Input tax is whatever tax amount adds up after acquiring the raw materials required for manufacturing his goods and services.  Output tax is the amount which adds up after selling the goods and services.

Calculation of VAT is therefore-

VAT = Output tax – Input tax 

VAT example :

Suppose Vikas owns a dairy farm and sell the dairy products for his earning. He will require a lot of raw materials in the form of fodder, medicines, etc. Now whatever he spends on maintaining the dairy is subjected to input tax and whatever is taxable on earning can be termed as output tax.

Now what VAT does is to eliminate the double payment of Tax for an individual who is a producer of goods or services by levying him only once.

VAT can be calculated in Excel too and it’s a very widely used method too for calculating VAT.

java code for VAT

Value-Added Tax (VAT) vs. Sales Tax

Even if both Sales tax and VAT adopt the same rate of taxation, VAT still is a better method of taxation as it involves all the different processes in the production and selling stage and eliminates loopholes when it comes to taxation to a large extent.

Java Program To Calculate VAT – Value-Added Tax

VAT or the Value Added Tax is the tax added to the amount of a particular product which denotes the increase in its value during its time of production and distribution. Our program here or the problem statement is to write a code for determining VAT for a certain set of input values.

The required input values are sales price from the wholesaler, VAT percentage and sales price margin from the retailer. These values can be of both integer or fraction and thereby, we make us of the double data type.

For any code to be efficient, it is always better for the code to be dynamic instead of any value being fixed. So, we make use of Scanner class in Java which reads inputs at runtime from the console screen instead of, giving the value directly in the code.

We first create an object referencing the Scanner class which is a system input class. Making use of this object, we read the input values at runtime of double type with the use of its method, nextDouble(). These can be done as follows:

With inputs in our hand, there are certain steps to be followed to arrive at our resultant VAT. We first calculate the input tax by making use of sales price from wholesaler and VAT percentage. The formula to calculate input tax is:

Then, making use of the sales price margin from the retailer, we add this margin to our earlier sales price.

This is our newly found sales price now. Then, we calculate the output tax using this sales price and the same VAT percentage. The formula is the same.

Our desired VAT  which is also of double type is nothing but, the difference between the input tax and the output tax. This gives us the increase in the value of the product. This can then be stored in another variable and displayed in the output screen as our resultant VAT or Value Added Tax.

vat=outputtax-inputtax;

Output: