Functions

my assigment, include these three functions

getsalesAmt
-this function prompts the user to enter a monthly sales amount.

the amount is read and assigned to a variable
the value is then returned to main ()

CalcCommission
- this function calculates the commission based on the sales amount.

if a salesperson sells more than 50,000. per month, the commission is 2% of the sales amount
if the sales are between 25,000 and 50,000 then the commission is 1.5% of the sales amount
however, if the sales are less than 25,000 there is no commission
the value is returned to main ()

calcPay
-this function calcuated the total monthly pay for a salesperson.

a sales person gets a monthly salary of 2,500 plus a commission, if the person has earned a commission
the values is returned to main ()

displayPay

format the output to two decimals places and with the amount aligned

include code to allow the user to run the program again



This is what i have so far. im stuck at the calculating pay function. please feel free to review my code for any mistakes.



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 <cstdlib>
#include <iostream>
#include <iomanip> // used for "setprecision"

using namespace std;

/*
 * 
 */
float getSalesAmt ( float );
float CalcCommission ( float );
float calcPay ( float pay);

int main(int argc, char** argv) {
    float sales;
    float commission;
    float calcPay;
    
    sales = getSalesAmt ();
    commission = CalcCommission();
    calcPay = calcPay();
    
    
    
    
    return 0;
}
float getSalesAmt (float sales)
{
    float sales;
    
    cout << "what was the monthly sales amount"<< endl;
    cin >> sales;
    return sales;
    
}
float CalcCommission ( float sales )
{
    float amount;
    if ( sales > 50000)
    {
        amount = .02 * sales;
    }
    else if ( sales > 25000 && sales < 50000)
    {
        amount = .015 * sales;
    } 
    else
    {
        cout << "no commission"<< endl;
    }
    return amount;
}
float calcPay (float amount)
{
    amount = amount + 2500;
    return amount;
    
}
Last edited on
Topic archived. No new replies allowed.