Write a program the inputs (from the user) the number of hours worked and hourly pay rate for employees and outputs their total pay. The program should process an arbitrary number of employees; the user will terminate input by entering 0 for hours worked and pay rate. Use a class called Worker with

Attributes: Hours, Rate, Total
Methods: Compute Total() and access methods (SetHours(), GetHours(), SetRate(), GetRate(), Set Total(), and Get Total()) for each of the attributes

Write a program the inputs (from the user) the number of hours worked and hourly pay rate for employees and outputs their total pay. The program should process an arbitrary number of employees; the user will terminate input by entering 0 for hours worked and pay rate. Use a class called Worker with

Attributes: Hours, Rate, Total
Methods: Compute Total() and access methods (SetHours(), GetHours(), SetRate(), GetRate(), Set Total(), and Get Total()) for each of the attributes

To write a program for calculating the total pay of employees based on the number of hours worked and hourly pay rate, you can follow these steps:

Step 1: Define the class "Worker" with the required attributes and methods. Here's an example implementation in Python:

```python
class Worker:
def __init__(self):
self.hours = 0
self.rate = 0
self.total = 0

def set_hours(self, hours):
self.hours = hours

def get_hours(self):
return self.hours

def set_rate(self, rate):
self.rate = rate

def get_rate(self):
return self.rate

def set_total(self, total):
self.total = total

def get_total(self):
return self.total

def compute_total(self):
self.total = self.hours * self.rate
```

The `Worker` class has four attributes: `hours`, `rate`, and `total`, which represent the number of hours worked, hourly pay rate, and total pay, respectively. It also has a constructor (`__init__`) to initialize the attributes, and accessors and mutators (getters and setters) for each attribute.

The `compute_total` method calculates the total pay by multiplying the hours worked with the hourly rate.

Step 2: Write the main program to handle user input and create instances of the `Worker` class. Here's an example in Python:

```python
workers = []

while True:
hours = float(input("Enter the number of hours worked (0 to terminate): "))
if hours == 0:
break

rate = float(input("Enter the hourly pay rate: "))

worker = Worker()
worker.set_hours(hours)
worker.set_rate(rate)
worker.compute_total()

workers.append(worker)

print("\nTotal pay for each worker:")
for worker in workers:
print(f"Total pay: {worker.get_total()}")
```

In the above program, we start by creating an empty list `workers` to store the instances of the `Worker` class.

We then use a while loop to continuously prompt the user for input until they enter 0 for the number of hours worked.

Inside the loop, we ask for the number of hours worked and the hourly pay rate, and create an instance of the `Worker` class. We set the hours and rate using the respective setter methods and compute the total pay using the `compute_total` method.

We finally append the `worker` object to the `workers` list.

After the loop ends, we loop through the `workers` list and print the total pay for each worker using the accessor method `get_total()`.

That's it! You have now written a program that calculates the total pay for an arbitrary number of employees based on their hours worked and hourly pay rate.