Function help

What im trying to do is pass the "sales amount" to the float calcCommision function. Im having difficulty understanding how to do that. Help please?
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
 #include <iostream>

using namespace std;

float getSalesAmt();
float calcCommision(float sales);
float calcPay(float pay);
void displayPay();

int main()
{
	float sales;
	float commision;

	sales = getSalesAmt();
	commision = calcCommision(float sales);




}

float getSalesAmt()
{
	float sales;
	float commision;

	cout << "Enter the monthly sales amount: ";
	cin >> sales; 

	return sales;

}
float calcCommision(float sales)
{
	float commision;

	if (sales > 50000)
	{
		float commision = sales * .02;

		return commision;
	}
	if (sales >= 25000 & sales <= 50000)
	{
		float commision = sales * .015;
		return commision;
	}
	else if (sales < 25000);
	{
		return commision;
	}
}
commision = calcCommision(float sales);

remove 'float' from this line. The type of variable 'sales' was set to 'float' earlier, so specifying it again here is an error.
yeah i fixed most of it al least i think now im having problem just displaying everything

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
#include <iostream>
#include <iomanip>
using namespace std;

float getSalesAmt();
float calcCommision(float getSalesAmt);
float calcPay(float calcCommision);
void displayPay(float & getSalesAmt, float & calcCommision, float & calcPay);

int main()
{
	float sales;
	float commision;
	float result;

	sales = getSalesAmt();
	commision = calcCommision(sales);
	result = calcPay(commision);

	displayPay(sales, commision, result);

	return 0;

}

float getSalesAmt()
{
	float sales;
	

	cout << "Enter the monthly sales amount: ";
	cin >> sales; 

	return sales;

}
float calcCommision(float getSalesAmt)
{
	if (getSalesAmt > 50000)
	{
		float commisions = getSalesAmt * 2 / 100;

		return commisions;
	}
	else if (getSalesAmt <= 50000 && getSalesAmt >= 25000)
	{
		float commisions = getSalesAmt * (1/5) / 100;
		return commisions;
	}

	else
	{
		float commisions = getSalesAmt * 0;
		return commisions;
	}
}
float calcPay(float calcCommision)
{
	float result;

	result = calcCommision + 25, 000;

    return result;

}
void displayPay(float getSalesAmt, float calcCommision, float calcPay)
{
	float basepay;

	cout << setw(18) << right << "Monthly Sales: " << "$" << getSalesAmt << endl << endl;
	cout << setw(18) << right << "Commision: " << "$" << calcCommision << endl << endl;
	cout << setw(18) << right << "Commision: " << "$" << basepay << endl << endl;




}
You must set the value of basepay to something before you print it out.
Topic archived. No new replies allowed.