Calculation

Boiko

Member
Joined
Jan 4, 2014
Messages
8
Location
United Kingdom
Programming Experience
Beginner
Hi guys,

Just reading a book for beginners about c# and just missed something here..
C#:
// Inputs
Console.Write("Enter customer price of a product: ");
string inputPrice = Console.ReadLine();
double customerPrice = Convert.ToDouble(inputPrice);


Console.Write("Enter VAT rate in %: ");
string inputVatRate = Console.ReadLine();
double vatRate = Convert.ToDouble(inputVatRate);


// Calculations
double divisor = [B]1[/B] + vatRate / 100.0;
why do we need that 1 +?

Thanks,

Tomas
 
This is basic maths, not programming. The final price is the initial price plus the tax. The 1 is for the initial price. If the tax rate was 10% then that calculation would be (1 + 10 / 100) or 1.1. If the original price was $100 then the final price with tax would be 1.1 x $100 or $110.
 
Back
Top Bottom