Write a program that 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 rate of pay. Use a class called Worker as follows:

Attributes: Hours, Rate, Total

Methods: ComputeTotal and access methods for each of the attributes

Start with a template and fill in the information as stipulated by the requirements. I do not see requirements for storing the data, so each instance of Worker will just request input, print the calculated results, and quit.

public class Worker{
// state variables: (define attributes)
...
// constructor (from hours, rate)
...
// Methods
// accessors for each attribute
...
// compute method, returns total
...

public static void main(String[] args){
// A while loop to request input,
// create an instance of Worker
// output data and total
// terminate while-loop when hours and rate are 0
...
}

}

Write a pseudocode to represent the logic of a program that allows a user to enter an hourly pay

rate and hours worked. The program outputs the user’s gross pay

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

1. Create a class called "Worker" with three attributes: hours, rate, and total.
2. Implement the class methods, which include:
- A constructor method to initialize the attributes when a new worker object is created.
- A method called "computeTotal" to calculate the total pay based on the hours worked and rate of pay. This method will update the "total" attribute with the calculated value.
- Accessor (getter) methods for each attribute to allow for accessing their values.

Here's an example implementation in Python:

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

def computeTotal(self):
self.total = self.hours * self.rate

def getHours(self):
return self.hours

def getRate(self):
return self.rate

def getTotal(self):
return self.total

# Main program
workers = []

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

if hours == 0:
break

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

worker = Worker(hours, rate)
worker.computeTotal()
workers.append(worker)

# Display the computed total pay for each worker
for worker in workers:
print("Total pay for worker with", worker.getHours(), "hours worked and hourly rate $", worker.getRate(), "is $", worker.getTotal())
```

In this program, we first define the `Worker` class with the necessary methods and attributes. Then, we create a list called `workers` to store multiple worker objects.

The program then enters a loop where the user is prompted to enter the number of hours worked. If the user enters 0, the loop breaks, terminating the input process. Otherwise, the user is prompted to enter the hourly pay rate. The program creates a new `Worker` object with the provided hours and rate, calculates the total pay using the `computeTotal` method, and appends the worker object to the `workers` list.

Finally, the program displays the total pay for each worker by iterating over the `workers` list, calling the getter methods to retrieve the values of hours, rate, and total for each worker.