Pointers not working?

closed account (S2ECpfjN)
Hello, I'm having an issue trying to get a code to work, its a call by Reference program, and I've gotten everything to work right, tax rate show up, dues, break down by hour ect. The thing is the taxes won't show...

example

Enter a rate between $10 and $15: 12.50

Enter hours worked between 1 and 50 for the week: 40

Hourly Rate: 12.50
Hours Worked: 40
Gross Pay: 500.00
FICA: 0.00 at 0.06
Federal Tax: 0.00 at 0.15
State Tax: 0.00 at 0.05
Union Dues: 10.00
NetPay: 489.74
NetHourly: 12.24

Thank you!

Press any key to continue . . .

the code I'm using is

void calcTax (double gross, double taxRate, double *taxAmount);

calcTax (gross, FICA_RATE, &fica);
calcTax (gross, FEDERAL_RATE, &federal);
calcTax (gross, STATE_RATE, &state);

void calcTax (double gross, double taxRate, double *taxAmount)
{
*taxAmount = gross * taxRate;
return;
}

any help is appreciated
You are missing out some vital information here:

1)Where and how do you declare/define fica, federal and state.
2)Your output code, as it's apparently the output that doesn't work properly
3) Use [code ] [ /code] tags around your code.
closed account (S2ECpfjN)
Okay I'll post the whole code instead of bits of it, its my first time.

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
//P06 Call-by-reference - Robert Ruckman
/*
	This program is used by customers to determine what the cost 
   of their order would be based on the price and quantity ordered.
*/

#include <iostream>  // cin, cout
using namespace std;

void inputRate  (double& rate);
void inputHours (int& hours);
void calcGross  (double rate, int hours, double& gross);
void calcTax (double gross, double taxRate, double *taxAmount);

double calcNetPay    (double gross, double FICA, double federal, double state, double UNION_DUES);
double calcNetHourly (double netpay, int hours);

const double OVERTIME_RATE = 1.5;

void main ()
{
	const double UNION_DUES = 10.00, FICA_RATE = (0.06),
			FEDERAL_RATE = (0.15), STATE_RATE = (0.05);

	int hours;
	double rate, gross, fica, federal, state, netPay, netHourly, taxRate, taxAmount;

	cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

	cout << "P06 Call by reference - Robert Ruckman \n\n";

	inputRate  (rate);
	inputHours (hours);

	calcGross (rate, hours, gross);
	calcTax   (gross, FICA_RATE, &fica);
	calcTax   (gross, FEDERAL_RATE, &federal);
	calcTax   (gross, STATE_RATE, &state);
	
	taxRate   = FICA_RATE, FEDERAL_RATE, STATE_RATE;
	gross     = rate * hours;
	taxAmount = gross * taxRate;
	netPay    = gross - (FICA_RATE + FEDERAL_RATE + STATE_RATE + UNION_DUES);
	netHourly = netPay / hours;

	cout << endl
		 << "Hourly Rate:   \t" << rate            << endl
		 << "Hours Worked:  \t" << hours           << endl
		 << "Gross Pay:     \t" << gross           << endl
		 << "FICA:          \t"	<< fica            << " at " << FICA_RATE    << endl
		 << "Federal Tax:   \t"	<< federal         << " at " << FEDERAL_RATE << endl
		 << "State Tax:     \t"	<< state           << " at " << STATE_RATE   << endl
		 << "Union Dues:    \t" << UNION_DUES      << endl
		 << "NetPay:        \t" << netPay          << endl
		 << "NetHourly:     \t" << netHourly       << endl;

	cout << "\nThank you!\n\n";

	return;
} // end of main

   int hours;
   double rate, gross, FICA_RATE, FEDERAL_RATE, STATE_RATE, UNION_DUES, netPay, netHourly;

void inputRate  (double& rate)
{
	do
	{
		cout << "Enter a rate between $10 and $15: ";
		cin >> rate;

	} while (rate < 10 || rate > 15);

	cout << endl;
	return;
}

void inputHours (int& hours)
{
	hours = 0;
	while (hours < 1 || hours > 50)
	{
		cout << "Enter hours worked between 1 and 50 for the week: ";
		cin >> hours;
	}
	return;
}

void calcGross (double, int, double& gross)
{
	if (hours > 40)
		gross = hours * (rate * OVERTIME_RATE);
	else
		gross = hours * rate;
	return;
}

void calcTax (double gross, double taxRate, double *taxAmount)
{
	*taxAmount = gross * taxRate;
	return;
}

double calcnetPay (double gross, double FICA_RATE, double FEDERAL_RATE, double STATE_RATE, double UNION_DUES)
{
	netPay = gross - (FICA_RATE + FEDERAL_RATE + STATE_RATE + UNION_DUES);
	return (netPay);
}

double calcNetHourly (double netpay, int hours)
{
	netHourly = netPay / hours;
	return (netHourly);
}

//end of program 
Apparently, the problem is that you didn't name the parameters in your calcGross function. Why this even compiles is beyond me.

Oh, and look at line 42 please. You have a statement there that... well, doesn't do very much.
closed account (S2ECpfjN)
Okay, wow I really need to watch what I type sometimes. Then again its always the small things that trip you up.

Also line 42 is there to initialize taxRate, otherwise it throws a warning.
No, what I mean is this:

 
taxRate   = FICA_RATE/* This part doesn't do anything: , FEDERAL_RATE, STATE_RATE*/;
Topic archived. No new replies allowed.