trouble getting decimal points

Hello, I'm having troubles getting an output. I want two decimal points in the output so for example:

Enter yearly income amount (0.0 to quit): $ 45000.00
The U.S. 1913 income tax = $450.00

When I do this however, it comes out $450 instead of $450.00

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//tax
#include <iostream>
using namespace std;

int main()
{
	double income = 0.00;

	cout << "Enter yearly income amount (0.0 to quit): $  ";
	cin >> income;

	if (income > 0.00 && income <= 50000.00)
	{
		cout << "The U.S. 1913 income tax = " << income*0.01 << endl;
	}

	else if (income > 50000 && income <= 75000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.02 << endl;
	}

	else if (income > 75000 && income <= 100000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.03 << endl;
	}

	else if (income > 100000 && income <= 250000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.04 << endl;
	}

	else if (income > 250000 && income <= 500000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.05 << endl;
	}

	else if (income > 500000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.06 << endl;
	}

	else
	{
		return 0;
	}

	return 0;

}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double income = 0.00;

	cout << "Enter yearly income amount (0.0 to quit): $  ";
	cin >> income;

    std::cout << std::fixed << std::setprecision(2);
	if (income > 0.00 && income <= 50000.00)
	{
		cout << "The U.S. 1913 income tax = " << income*0.01 << endl;
	}

	else if (income > 50000 && income <= 75000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.02 << endl;
	}

	else if (income > 75000 && income <= 100000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.03 << endl;
	}

	else if (income > 100000 && income <= 250000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.04 << endl;
	}

	else if (income > 250000 && income <= 500000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.05 << endl;
	}

	else if (income > 500000)
	{
		cout << "The U.S. 1913 income tax = " << income*0.06 << endl;
	}

	else
	{
		return 0;
	}

	return 0;

}

Topic archived. No new replies allowed.