Greetings,
There are a few syntatical errors in your program. Let's walk through them one step at a time.
Point A
First issue is the local variables themselves. Nothing major, it can be fixed. Let's look at what we have:
const price*=sales_tax_rate,
price of item,
sales_tax,
total;
Alright, this may cause a few errors if not a ton. I see you declared price as aconstant variable that equals sales_tax_rate, though there is no trace of such a variable here. Of course you are initializing a constant variable for the rest without a data type. Since prices and percentages work with decimals alot, lets make these variables floating-type variables:
int main() {
float item_price, sales_tax, total;
float sales_tax_rate = .081f;
All four variables are floats. The last variable,sales_tax_rate is 8.1% in decimal style, or 0.81. The f is there to tell the compiler this is a float not a double. That is on an enitrely different topic, so lets move to the next step.
Point B
Secondly we need to input from the user to store in our float item_price. This is easy:
//Display price of item
cout << "Enter the price of the item: ";
cin >> item_price;
As you may see we used cout and cin. Each ending with a semi-colon to break that lines worth of code. Without that semi-colon, the next line may whine about how a computation that started never ended.Point C
Here we calculate our tax by multiplying the items price by the tax rate we set as 0.81.
//calculate tax
sales_tax = item_price * sales_tax_rate;
total = item_price + sales_tax;
This is quite simple. The equation is set to sales_tax, and the total adds it to the price, etc...
Of course we just display it now:
//Display price and total
cout << "\nprice of item: " << item_price;
cout << "\nsales tax: " << sales_tax;
cout << "\ntotal amount: " << total;
return 0;
}
If you have further questions, please feel free to ask.
-Stack Overflow