1. Using repetition control structure (do while loop), prepare a program that can receive employee id and working hour(s) for three (3) employees.
    The program able to:
    i. calculate Overtime Payment using formula Overtime = Working hours * 35.00 for each employee
    ii. calculate Total Overtime Payment for all employees
    iii. calculate Average Of Overtime Payment for each employee
    The suggestion output is shown as below.
    Enter Employee ID :psp01 Enter working hour :10 Working hour is: 10 Overtime Payment is: RM350
    Enter Employee ID psp02 Enter working hour :8 Working hour is: 8 Overtime Payment is: RM280
    Enter Employee ID :psp03
    Enter working hour 12 Working hour is: 12
    Overtime Payment is: RM420
    Total Overtime Payment: RM1050 Average Overtime Payment: RM350

How can I get this source code?

It's a learning assignment. You get the source code by writing it yourself - that's how you learn.

If you are trying to write it, and you're stuck, explain what you have done so far and what's blocking you. Someone will help.

This should do what you asked.

#include <iostream>
using namespace std;

int main() {
    int i = 1;
    float working_hours, overtime_payment, total_overtime_payment = 0;
    float average_overtime_payment;
    string employee_id;

    do {
        cout << "Enter Employee ID: ";
        cin >> employee_id;
        cout << "Enter working hour: ";
        cin >> working_hours;

        overtime_payment = working_hours * 35.00;
        total_overtime_payment += overtime_payment;

        cout << "Working hour is: " << working_hours << endl;
        cout << "Overtime Payment is: RM" << overtime_payment << endl;

        i++;
    } while (i <= 3);

    average_overtime_payment = total_overtime_payment / 3;

    cout << "Total Overtime Payment: RM" << total_overtime_payment << endl;
    cout << "Average Overtime Payment: RM" << average_overtime_payment << endl;

    return 0;
}

Enter Employee ID: psp01
Enter working hour: 10
Working hour is: 10
Overtime Payment is: RM350
Enter Employee ID: psp02
Enter working hour: 8
Working hour is: 8
Overtime Payment is: RM280
Enter Employee ID: psp03
Enter working hour: 12
Working hour is: 12
Overtime Payment is: RM420
Total Overtime Payment: RM1050
Average Overtime Payment: RM350

Do While Loop Basic Step: Open Dev C++ then File > new > source file and start writing the code below.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.