Percentages
How do I add tax in c++
Taxes are numbers, so you add a tax the same way you would add any numbers together in C++.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
double price, tax, endPrice;
//get input from user
std::cout << "\nWhat is price to be taxed?";
std::cin >> price;
//get tax percentage from user
std::cout << "\nWhat is tax rate (in %)?";
std::cin >> tax;
//calculate final price
endPrice = price + (tax / 100 * price);
//Display price with taxes
std::cout << "\nEnd price is: " << endPrice << "\n";
|
Topic archived. No new replies allowed.