Finding number of people with score below average

Hi, I have created a programme that calculates the pay of 10 artists based on the hours they worked and their average pay.
What I need to do now is to find the number of artists who have a pay lower than the average.
Ive been searching through the internet for clues but cant seem to find any related topics to such a question

My question is:
Which C++ concepts would I have to use? (My c++ knowledge so far is up till functions and arrays)

Are there any links you guys can share for me to reference/ learn from?
Thanks!

My code isn't really needed here but in case you need a sense of what im talking about:

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
     int totalStaffHours;
    int totalStaffPay;
    int allPay =0;
    int averagePay =0;

    cout << "\n\n";
    cout << "===================================\n";
    cout << "Pay Report: \n";
    cout << setw(12) << "\t\t";
    cout << setw(10) << "Hours \n";

     for (int x=0; x < staff; x++)
    {

        //To refresh the totalStaff Hours & Pay count
        totalStaffHours = 0;
        totalStaffPay =0;

        for (int y=0; y < hours; y++)
        {


        totalStaffHours += staffHours[x][y];

        }

    if (totalStaffHours <=30)
    {
        totalStaffPay = totalStaffHours *10;
    }

    else
    {
        totalStaffPay = 30*10 + (totalStaffHours - 30) * 10 * 1.5;
    }


    cout << setw(12) << artists[x] << "= $" << totalStaffPay ;
    cout << setw (10) << "\t" << totalStaffHours;
    cout << endl;

    allPay += totalStaffPay;
    averagePay = allPay / staff;
Last edited on
functions and arrays is enough.
Found the solution:
if else within the loop
For future references if anyone needs it.

Insipration: http://www.cplusplus.com/forum/beginner/148335/

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
    for (int x=0; x < staff; x++)
    {

        //To refresh the totalStaff Hours & Pay count
        totalStaffHours = 0;
        totalStaffPay =0;

        for (int y=0; y < hours; y++)
        {


        totalStaffHours += staffHours[x][y];

        }

    if (totalStaffHours <=30)
    {
        totalStaffPay = totalStaffHours *10;
    }

    else
    {
        totalStaffPay = 30*10 + (totalStaffHours - 30) * 10 * 1.5;
    }


    cout << setw(12) << artists[x] << "= $" << totalStaffPay ;
    cout << setw (10) << "\t" << totalStaffHours;
    cout << endl;

    allPay += totalStaffPay;
    averagePay = allPay / staff;

        if (totalStaffPay <= averagePay)
        {
            belowAverage++;
        }

        else
        {
            aboveAverage++;
        }



    }

    cout << "\n\n";
    cout << "Average Pay: $" << averagePay << endl;
    cout << "Number of Artists lower or equal than Average Pay= " << belowAverage << endl;

    cout << "=================================== \n";
    cout << endl;
}
Last edited on
Topic archived. No new replies allowed.