Beginner sales tax calculator

I'm not sure how to make a code where I could calculate sales tax and keeping the total showing 2 decimal places. This is how far I got, but for some reason my total keeps displaying 0.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;

int main(){
	double salesPrice;
	double total=salesPrice*0.0875;
	
	
	cout<<"Enter Sales Price:\n";
	cin>>salesPrice;
	cout<<"Total: $"<<total<<endl;

	}
double total=salesPrice*0.0875;

You're doing the calculation before the user enters the sale price, that's not what you want is it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main(){
	double salesPrice;
	double total;
	
	
	cout<<"Enter Sales Price:\n";
	cin>>salesPrice;
        total = salesPrice * 0.0875;
	cout<<"Total: $"<<total<<endl;

}
Topic archived. No new replies allowed.