Below is the Raptor program to input a list of employee names and salaries and store them in parallel arrays, find the average of all the salaries, and find the names and salaries of any employee who's salary is within 5,000 of the average:
Python
# Define the number of employees
numEmployees = 10
# Create arrays to store employee names and salaries
employeeNames = []
employeeSalaries = []
# Input employee names
for i in range(numEmployees):
employeeName = input("Enter employee name: ")
employeeNames.append(employeeName)
# Input employee salaries
for i in range(numEmployees):
employeeSalary = float(input("Enter employee salary (even thousands): "))
employeeSalaries.append(employeeSalary)
# Find the average salary
averageSalary = sum(employeeSalaries) / len(employeeSalaries)
# Find employees within 5,000 of the average salary
withinRange = []
for i in range(numEmployees):
if abs(employeeSalaries[i] - averageSalary) <= 5.0:
withinRange.append([employeeNames[i], employeeSalaries[i]])
# Display employees within 5,000 of the average salary
for employee in withinRange:
print(f"Employee: {employee[0]} | Salary: {employee[1]}")