Income tax calculator

I am stuck writing this income tax calculator. It compiles and works with the right math on the income. My problem is the loop where I ask for a married or single status line 33, it automatically comes back as an invalid character. Let me know if you see a mistake that I am not seeing. The other question that I have is with my first do while loop line 18, I am not sure how to get this to work when they enter an invalid income. Thanks for your help.
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# include <iostream>
# include <string>

using namespace std;

int main()
{
	double taxableIncome;
	double incomeTax;
	double error;
	string returnType;
	char tryAgain;
	bool isAgain = false;
	
	cout << "Kirk's Tax Calculator";
	cout << "\nCS 1410 Project #8" << endl;

	do
	{
		error = 0;
		cout << "\nPlease enter in your taxable income.";
		cout << "\nThis must be a positive value: ";
		cin >> taxableIncome;
		if (cin.fail())
		{
			cout << "Please enter a valid integer" << endl;
			error = 1;
			cin.clear();
			cin.ignore(80, 'n');
		}
	} while (error == 1);
	
	do
	{
		isAgain = false;
		cout << "\nPlease enter an \"m\" if married and filing joint return,";
		cout << "\nor \"s\" if filing a single return or married filing separate return: " << endl;
		getline(cin, returnType);
		if (returnType == "m")
		{
			if (taxableIncome > 0 && taxableIncome < 1726)
			{
				incomeTax = (((taxableIncome - 0)*.023) + 0);
			}
			if (taxableIncome > 1726 && taxableIncome < 5176)
			{
				incomeTax = (((taxableIncome - 1726)*.033) + 40);
			}
			if (taxableIncome > 5176 && taxableIncome < 8626)
			{
				incomeTax = (((taxableIncome - 5176)*.052) + 175);
			}
			if (taxableIncome >  8626)
			{
				incomeTax = (((taxableIncome - 8626)*.075) + 390);
			}
			cout << "\nYour taxable income is $" << taxableIncome;
			cout << "\nand you are filing a joint return." << endl;
			cout << "Your income tax will be $" << incomeTax << endl;
		}
		else
			if (returnType == "s")
			{
				if (taxableIncome > 0 && taxableIncome < 863)
				{
					incomeTax = (((taxableIncome - 0)*.023) + 0);
				}
				if (taxableIncome > 863 && taxableIncome < 2588)
				{
					incomeTax = (((taxableIncome - 863)*.033) + 25);
				}
				if (taxableIncome > 2588 && taxableIncome < 4313)
				{
					incomeTax = (((taxableIncome - 2588)*.052) + 85);
				}
				if (taxableIncome >  4313)
				{
					incomeTax = (((taxableIncome - 4313)*.075) + 181);
				}
				
				cout << "\nYour taxable income is $" << taxableIncome;
				cout << "\nand you are filing a single return." << endl;
				cout << "Your income tax will be $" << incomeTax << endl;
			}
		else
		{
			isAgain = true;
			cout << "that is an invalid character" << endl;
		}

	} while (isAgain);

	system("PAUSE");
	return 0;
}
A classic getline (line 38) after formatted extraction (line 23) problem.
http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction
Okay the corrected line 38 is, I am still curious what to do about the first do loop asking for a valid input.
 
		cin >> returnType;
this is the code I am looking at for that loop, I am trying to get the value if negative to go back to the starting question.
1
2
3
4
5
6
7
8
9
10
11
12
	do
	{
		error = 0;
		cout << "\nPlease enter in your taxable income.";
		cout << "\nThis must be a positive value: ";
		cin >> taxableIncome;
		if (taxableIncome < 0)
		{
			cout << "Please enter a valid integer" << endl;
			cin.clear();
		}
	} while (taxableIncome > 0);
I have figured this one out, thanks for your response MiiNiPaa.
Topic archived. No new replies allowed.