我正在用 C++ 编写一个简单的程序来计算购买的税款并输出它。我的代码正在输出设置但未更改的文本和变量。但是,它没有输出根据税率计算和设置的变量,而是输出 0。感谢您的帮助!对我来说第一周的课,所以如果可以的话,试着把它变笨:)
这是代码:
#include <iostream>
using namespace std;
int main()
{
int price = 52, stateTaxRate = 4, countyTaxRate = 2;
double stateTax = price / 100 * stateTaxRate;
double countyTax = price / 100 * countyTaxRate;
double totalTax = countyTax + stateTax;
double total = price + totalTax;
cout << "State Tax: " << stateTax << " ";
cout << "County Tax: " << countyTax << " ";
cout << "Total Tax: " << totalTax << " ";
cout << "Total: " << total << " ";
}