122k views
0 votes
This is your final exam Part 2. Create the follow program using Raptor. Use the concepts, techniques and good programming practices that you have learned in the course. You have unlimited attempts for this part of the exam.

Input a list of employee names and salaries and store them in parallel arrays. End the input with a sentinel value. The salaries should be floating point numbers Salaries should be input in even thousands. For example, a salary of 36,510 should be input as 36.5 and a salary of 69,030 should be entered as 69.0. Find the average of all the salaries of the employees. Then find the names and salaries of any employee who's salary is within 5,000 [5.0] of the average. So if the average is 30,000 and an employee earns 33,000, his/her name would be found.

User Abdu
by
8.2k points

1 Answer

3 votes

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]}")

User Ezvine
by
7.9k points