working w/arrays

I have gotten this far with this prog. but need urgent help.the prog will compute tax for individuals income upto 6000(row 1) 10000(row 2)15000...,20000..., 25000..., 30000.., over 35000 pay 35% rate. Cannot get the if/else statement going in right direction to pick up arrays. the filing status should be a string. Any help is appreciated Thanks

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
#include<stdlib.h>
#include<stdio.h>
#include<iostream>


double getDouble(char prompt[30]);
int getInt(char prompt[30]);
void printReport(int, char,double);


int main()
{
	double wages=0.0, interest=0.0, dividends=0.0, otherIncome = 0.0, taxOwed = 0.0, totIncome =0.0;
	int noDep=0,processed=0;
	//strcpy (status);
	double taxes[7][5]={
		{2.8, 0.0, 2.3, 0.0},
		{7.5, 5.2, 7.2, 3.8},
		{9.6, 8.3, 8.9, 7.4},
		{13.5, 12.2, 13.1, 11.0},
		{15.5, 14.6, 15.2,13.8},
		{17.4, 16.3, 17.2, 15.4}
	};
	char status[]={'S', 'MJ', 'MS', 'SH','Q'};

	
	printf("Welcome to the Income Tax Calculator \n\n");
	printf("Filing Status \n S  = single\n MJ = married filing joint\n MS = married filing seperate\n SH = single head of household\n Q = quit\n");
	printf("Enter your filing status: ");
	scanf_s("%3c", &status);
	if(status != "Q")
	{
		
		printf("Enter your amount of Wages:$ ");
		scanf_s("%10f",&wages);
		printf("Enter amount of interest:$ ");
		scanf_s("%10f",&interest);
		printf("Enter amount of Dividends:$ ");
		scanf_s("%10f",&dividends);
		printf("Enter amount of any other income:$ ");
		scanf_s("%10f",&otherIncome);
		printf("Enter number of Dependents: ");
		scanf_s("%2d",&noDep);
	}

		totIncome = (wages + interest + dividends + otherIncome) - (noDep * 2800);
		if(totIncome <= 6000)
			printf("Tax owed: %f\n",&taxes);
		else if( totIncome <= 10000)
				taxOwed = 168.00 + (totIncome - 6000)* .075;
			//else if(totIncome <= 15000)
			//	taxOwed = 
		//printReport(processed,&status,taxOwed);
		//system("pause");

	return 0;
}

double getDouble(char prompt[30])
{
    double d;
    char buffer[30];
    printf("%c", prompt);
    gets_s(buffer);
    d = atof(buffer);
    return d;
}
int getInt(char prompt[30])
{
    int i;
    char buffer[30];
    printf("%s", prompt);
    gets_s(buffer);
    i = atoi(buffer);
    return i;
}
/*void printReport(int processed, char status, double taxOwed)
{
    printf("\nTotal # records %ti STATUS %c", processed, status);
    printf("\nIncome Tax Owed: %.2f\n", taxOwed);

}*/
What exactly is your question?
When I run the program it does not come up with the right values; am I doing something wrong w/the if/else or should I use a switch statement?
I have got most of this running right, it just isn't outputting the correct info I guess do to 'referencing'?? need help getting the output from the table when called also the print report is printing garbage. how to fix?????

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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

double getDouble(char prompt[30]);
int getchar(char prompt[30]);
void printReport(char,char,char,char);


int main()
{
	double wages=0.0, interest=0.0, dividends=0.0, otherIncome = 0.0, taxOwed = 0.0, totIncome =0.0;
	int noDep=0;
	char status[4];
	
	double taxes[7][5]={
		{2.8, 0.0, 2.3, 0.0},
		{7.5, 5.2, 7.2, 3.8},
		{9.6, 8.3, 8.9, 7.4},
		{13.5, 12.2, 13.1, 11.0},
		{15.5, 14.6, 15.2,13.8},
		{17.4, 16.3, 17.2, 15.4}
	};
	
	int t;
	int i;
	for(t=0; t<7; t++);
		for(i=0; i<5; i++);
		{
			printf("%.2f", taxes[t][i]);
		}
	
	printf("Welcome to the Income Tax Calculator \n\n");
	printf("Filing Status \n S  = single\n MJ = married filing joint\n MS = married filing seperate\n SH = single head of household\n Q = quit\n");
	
	while(strcmp(status, "Q")!= 0)
	{
		printf("Enter your filing status: ");
		scanf_s("%3s", &status,4);
		//printf("You entered %s\n", status);
		printf("Enter your amount of Wages:$ ");
		scanf_s("%lf",&wages);
		//printf("You entered %lf\n", wages);
		printf("Enter amount of interest:$ ");
		scanf_s("%lf",&interest);
		//printf("You entered %lf\n", interest);
		printf("Enter amount of Dividends:$ ");
		scanf_s("%lf",&dividends);
		//printf("You entered %lf\n", dividends);
		printf("Enter amount of any other income:$ ");
		scanf_s("%lf",&otherIncome);
		//printf("You entered %lf\n", otherIncome);
		printf("Enter number of Dependents: ");
		scanf_s("%2d",&noDep);
		//printf("You entered %d\n", noDep);
		totIncome = (wages + interest + dividends + otherIncome) - (noDep * 2800);
		printf("Total Income:$ %.2f\n",totIncome);
		if(totIncome <= 6000)
		{
			printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if( totIncome > 6001 && totIncome < 10000)
		{
				printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if(totIncome > 10001 && totIncome <= 15000)
		{
				printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if(totIncome > 15001 && totIncome <= 20000)
		{
				printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if(totIncome > 20001 && totIncome <= 25000)
		{
				printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if(totIncome > 25001 && totIncome <= 30000)
		{
				 
				printf("Tax owed: %.2f\n",taxes[t][i]);
		}
		else if (totIncome >= 30001)
		{
			taxOwed = totIncome * .35;
			printf("Tax owed: %.2f\n",taxOwed);
		}


	}
		system("pause");
		
		//printReport( );		
		

	return 0;
}

double getDouble(char prompt[30])
{
    double d;
    char buffer[30];
    printf("%c", prompt);
    gets_s(buffer);
    d = atof(buffer);
    return d;
}
int getchar(char prompt[30])
{
    int i;
    char buffer[30];
    printf("%s", prompt);
    gets_s(buffer);
    i = atoi(buffer);
    return i;
}
int getint(char prompt[30])
{
    int i;
    char buffer[30];
    printf("%d", prompt);
    gets_s(buffer);
    i = atoi(buffer);
    return i;
}

void printReport(char single,char marriedJoint, char marriedSeperate, char singleHead)
{
	printf("SINGLE  %d\nMARRIED JOINT	%d\nMARRIED SEPERATE	%d\nSINGLE HEAD  %d\n",single,marriedJoint,marriedSeperate,singleHead);
		    

}
I have made some changes to the program but with change came more trouble; errors listed:
f:\cpt244\income tax calculator solution\income tax calculator project\tax calculator.cpp(33) : error C2446: '<=' : no conversion from 'double *' to 'double'
There is no context in which this conversion is possible
f:\cpt244\income tax calculator solution\income tax calculator project\tax calculator.cpp(33) : error C2440: '<=' : cannot convert from 'double [6]' to 'double'
f:\cpt244\income tax calculator solution\income tax calculator project\tax calculator.cpp(61) : error C2065: 'taxStat' : undeclared identifier

this is the program & any help is appreciated!
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
#include<stdlib.h>
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int find_tax_rate(double income, double taxStat);
//void printReport(char,char,char,char);


int main()
{
	double wages=0.0, interest=0.0, dividends=0.0, otherIncome = 0.0, taxOwed = 0.0, totIncome =0.0;
	int noDep=0;
	string status[4];
	
	double inc[7][6]={
		{6000.0,2.8, 0.0, 2.3, 0.0},
		{10000.0,7.5, 5.2, 7.2, 3.8},
		{15000.0,9.6, 8.3, 8.9, 7.4},
		{20000.0,13.5, 12.2, 13.1, 11.0},
		{25000.0,15.5, 14.6, 15.2,13.8},
		{30000.0,17.4, 16.3, 17.2, 15.4}
	};
		int x;
		int y;
		for(x=0; x<7; x++);
			if (totIncome<= inc[x])
            {
                y=x;
                x=7;
			}
	
	printf("Welcome to the Income Tax Calculator \n\n");
	printf("Filing Status \n S  = single\n MJ = married filing joint\n MS = married filing seperate\n SH = single head of household\n Q = quit\n");
		printf("Enter your filing status: ");
		scanf_s("%3s", &status,4);
		//printf("You entered %s\n", status);
		printf("Enter your amount of Wages:$ ");
		scanf_s("%lf",&wages);
		//printf("You entered %lf\n", wages);
		printf("Enter amount of interest:$ ");
		scanf_s("%lf",&interest);
		//printf("You entered %lf\n", interest);
		printf("Enter amount of Dividends:$ ");
		scanf_s("%lf",&dividends);
		//printf("You entered %lf\n", dividends);
		printf("Enter amount of any other income:$ ");
		scanf_s("%lf",&otherIncome);
		//printf("You entered %lf\n", otherIncome);
		printf("Enter number of Dependents: ");
		scanf_s("%2d",&noDep);
		//printf("You entered %d\n", noDep);
		totIncome = (wages + interest + dividends + otherIncome) - (noDep * 2800);
		printf("Total Income:$ %.2f\n",totIncome);
		if(!strcmp(taxStat,"S")
		{
            tr = S[y];
		}
        else if(!strcmp(taxStat,"MS")
		{
            tr = MS[y];
		}
        else if (!strcmp (taxStat,"MJ")
		{
            tr = MJ[y];
		}
		if (totIncome >= 30001)
		{
			taxOwed = totIncome * .35;
			printf("Tax owed: %.2f\n",taxOwed);
		}


	
		system("pause");
		
		//printReport();		
		

	return 0;
}

int find_tax_rate(double income, double taxStat)
{
	
}
void printReport(char single,char marriedJoint, char marriedSeperate, char singleHead)
{
	

	printf("SINGLE  %d\nMARRIED JOINT	%d\nMARRIED SEPERATE	%d\nSINGLE HEAD  %d\n",single,marriedJoint,marriedSeperate,singleHead);
		    

}
Topic archived. No new replies allowed.