HELP

THIS IS MY CODE

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
#include <iostream>
#include <math.h>
#include <string>

using namespace std;


int main()
{

	// declare variables

	int salary; // income
	int status;
	int single; 
	int married; 

	string taxFee ; 
	double taxPercent ; 
	double tax;

	// get input from user

	cout << "what is your income?";
	cin >> salary;
	cout << "married or single";
	cin >> single || married

	// processing


	if ( status == single)
	
	if ((salary >= 0) && (salary < 25000))
	{
		taxFee = "single first class tax";
		taxPercent = .10;
	}
	else if ((salary >= 25000) && (salary < 75000))
	{
		taxFee = "single second class tax";
		taxPercent = .20;
	}
		else if ((salary >= 75000) && (salary < 125000))
	{
		taxFee = "single third class tax";
		taxPercent = .30;
	}
		else if (salary <= 125,000)
	{
		taxFee = "single fourth class tax";
		taxPercent = .40;
	}
	if ( status == married)

	if ((salary >= 0) && (salary < 25000))
	{
		taxFee = "married first class tax";
		taxPercent = .08;
	}
	else if ((salary >= 25000) && (salary < 75000))
	{
		taxFee = "married second class tax";
		taxPercent = .15;
	}
		else if ((salary >= 75000) && (salary < 125000))
	{
		taxFee = "married third class tax";
		taxPercent = .25;
	}
		else if (salary <= 125,000)
	{
		taxFee = "married fourth class tax";
		taxPercent = .30;
	}

	// do processing

	tax = salary * taxPercent;

	// output results
	cout << "based on the salary" << taxFee << " for $" << taxPercent << endl;
	cout << "your total tax is $" << tax << " per month" << endl;


	system("PAUSE");
	return 0;
}


HOW DO I FIX IT
Last edited on
Fix what? What problem are you having?
First things first: not that I hold it against you, but you technically aren't supposed to post forum questions called "HELP".

Now, first, go with cin.get(); instead of that dreadful system("PAUSE"); and then your function will not give non-Bloodshed coders conniptions.

Second. you cannot cin>>single || married. I know your motives were right, but how is the poor processor supposed to choose? Go with a standard char choice and make the choices "s" or "m". Then take the answer and use it to assign either true or false to a bool called isMarried. Then get rid of all your status, single, or married stuff, because the processor can't understand that.

An anonymous coder wrote:
A program is like a car wash that washes your car, but leaves it soapy. It hasn't been told to rinse.


Repost with corrections:
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
96
97
#include <iostream>
#include <math.h>
#include <string>

using namespace std;


int main()
{

	// declare variables

	int salary; // income
	bool isMarried;
	char choice; 

	string taxFee; 
	double taxPercent; 
	double tax;

	// get input from user

	cout << "what is your income?"<<endl;//the endl additions are just for prettiness's sake.
	cin >> salary;
	cout << "married or single? (M/S)"<<endl;
	cin >> choice;
        if(choice == 'm' || choice == 'M')
                isMarried = true;
        else if(choice == 's' || choice == 'S')
                isMarried = false;
        else
        {
                cout<<"That wasn't a choice. Please restart program.";
                return 0;
        }

	// processing


    if (!isMarried)
    {
	if ((salary >= 0) && (salary < 25000))
	{
		taxFee = "single first class tax";
		taxPercent = .10;
	}
	else if ((salary >= 25000) && (salary < 75000))
	{
		taxFee = "single second class tax";
		taxPercent = .20;
	}
		else if ((salary >= 75000) && (salary < 125000))
	{
		taxFee = "single third class tax";
		taxPercent = .30;
	}
		else if (salary <= 125,000)
	{
		taxFee = "single fourth class tax";
		taxPercent = .40;
	}
    }
    else if (isMarried)
    {
	if ((salary >= 0) && (salary < 25000))
	{
		taxFee = "married first class tax";
		taxPercent = .08;
	}
	else if ((salary >= 25000) && (salary < 75000))
	{
		taxFee = "married second class tax";
		taxPercent = .15;
	}
		else if ((salary >= 75000) && (salary < 125000))
	{
		taxFee = "married third class tax";
		taxPercent = .25;
	}
		else if (salary <= 125,000)
	{
		taxFee = "married fourth class tax";
		taxPercent = .30;
	}
    }
	// do processing

	tax = salary * taxPercent;

	// output results
	cout << "based on the salary" << taxFee << " for $" << taxPercent << endl;
	cout << "your total tax is $" << tax << " per month" << endl;


	cin.get();
	return 0;
}


Hope I helped.
Last edited on
Topic archived. No new replies allowed.