total commission is correct?


Here the code:

1
2
3
4
5
6
7
8
9
#include<iostream>

using namespace std;

void sales_amount();
//void commission_percentage();
//void commission_total();


Am i wrong about my code to follow the problem?
Thanks
Last edited on
closed account (28poGNh0)
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
# include <iostream>
# include <limits.h>
using namespace std;


void calculatecomm(float &y)
{
    y = float(y) * 0.1;
}

void displaycomm(float x)
{
    cout << " The commission is : " << x << " $ " << endl;
}

void totalcomm(float total)
{
    cout << " total : " << total << endl;
}

float getsales(void)
{
    int var = 0;
    cout << "Enter sales amount -> ";
    cin >> var;

    return var;
}

int main()
{
    float comSum = 0;

    for (int i=0;;i++)
    {
        float tmpVar = getsales();
        if(tmpVar<0)break;
        calculatecomm(tmpVar);
        displaycomm(tmpVar);
        comSum += tmpVar;
    }

    totalcomm(comSum);

    cin.ignore(INT_MAX,'\n'));
}
Last edited on
How to get the total commissionair?
closed account (28poGNh0)
This is the job of the functino totalcomm(int);
how about for loop for sentinel value?
Topic archived. No new replies allowed.