help with sales commission program

so this program works, but my professor wanted my function to have paramters sale amount and sales commission, not sure what he means by that, as we are trying t find the sales commission
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
  #include <iostream>
#include <iomanip>
using namespace std;
double commCalc(double s, int c);
int main() 
{
	double s;
	int c;
	
	cout << " This is a sales commission calculator " << endl;
	
	
	cout << " Please enter the sale price: $";
		cin >> s;
		cout << "Are you the:" << endl;
		cout << "1. Sales person" << endl;
		cout << "2. Loan officer" << endl;
		cin >> c;
		
	double sales = commCalc(s, c);
	cout << " Your sales commission is: $"  << sales << endl;
	
	
	system("pause");
	return 0;
		

}
double commCalc(double s, int c)
{
	 if (c = 1) 
	 {
		if (s >= 12000.01 || s <= 22000)
		{
			return (s * .03);
		}
		if (s >= 22000.01) {
			return (s * .05);
		}
		else
		{
			return (s * .02);
		}
	 }
	if (c = 2)
	{
		if (s >= 12000.01 || s <= 22000)
		{
			return (s *  .005);
		}
		if (s >= 22000.01)
		{
			return (s * .008);
		}
		else
		{
			return (s * .009);
		}
	}
}
Yes, the program works. I am also not sure what he means. Maybe he wants you to use "meaningful names"
double commCalc(double s, int c)
This can be improved in two ways
1. Give the function a name that tells what it does
2. Give the input parameters names that convey meaning. What does s stand for? sales, salary, sandBags?

Maybe he wants you to do (just a guess)
1
2
3
double commCalc(double saleAmount, int saleCommission); 
// or
double calculateCommission(double saleAmount, int saleCommission); 
Last edited on
Topic archived. No new replies allowed.