Percentages

Sep 14, 2018 at 11:08pm
How do I add tax in c++

Sep 14, 2018 at 11:28pm
closed account (E0p9LyTq)
Taxes are numbers, so you add a tax the same way you would add any numbers together in C++.
Sep 15, 2018 at 10:06am
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.