Question
Python Coding Assignment Input a list of employee names and salaries stored in parallel arrays . The salaries should be floating point numbers in increments
Python Coding Assignment
Input a list of employee names and salaries stored in parallel arrays. The salaries should be floating point numbers in increments of 1000 (note: the book says 100, but it is wrong). For example, a salary of $36,000 should be input as 36.0 and a salary of $85,900 should be input as 85.9. Find the mean (average) salary without using any Python sum or average functions and display the names and salaries of employees who earn within a range of $5,000 from the mean. In other words, if the mean salary is $45,000, all employees who earn between $40,000 and $50,000 should be displayed. Don't forget to use a main() function and any other functions as needed such as one that gets integers.
----------------------------------------------------
Output/Interaction should look like this:
Please enter the employee name or * to finish: Dave Please enter the salary in thousands for Dave: 50 Please enter the employee name or * to finish: Edward Please enter the salary in thousands for Edward: 48 Please enter the employee name or * to finish: Frank Please enter the salary in thousands for Frank: 52 Please enter the employee name or * to finish: George Please enter the salary in thousands for George: 0.010 Please enter the employee name or * to finish: Harry Please enter the salary in thousands for Harry: 100 Please enter the employee name or * to finish: * Dave, 50000.00 Edward, 48000.00 Frank, 52000.00
-------------------------------------------------------------
If possible, please use these comments following the code. Comment included in final code.
# function to get a floating point number # if successful the floating point number will be returned # otherwise the user will have to continue attempting to enter the number # @param m is the prompt to the user. # @return a floating point number supplied by the user # infinate loop to acquire the score # try to turn s into a float # successful ~ leave the loop and return the score # float cast failed ~ message user and try again # program main ~ entry point of execution # declare the data arrays # flag as loop control variable # get employee names and saleries until the sentinal is entered # get the employee's name # check for a '*' to see if we are done or not # no '*' so we keep going # set a prompt for getting the salary # use the getFloat method from last assignment to get the earnings for the employee # and convert it from "in thousands" to the true value # append the employee name to the employee array # append the salary to the parallel salary array # otherwise we are done # now that we have the employees, we can find the average using a loop and dividing by the array length # set the accumulator for the total # find the grand total # calculate the avarage salary # now that we have the average salary we can start looking at the employees and comparing them using a loop # set the minumum and maximum threshholds for testing # loop through all the employees and test them to see if they are in the salary range # if the salary for the employee is greater than the min and less than the max thresholds print employee info # execute the application
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started