Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def validate _ float _ input ( prompt ) : while True: try: value = float ( input ( prompt ) ) return value except
def validatefloatinputprompt:
while True:
try:
value floatinputprompt
return value
except ValueError:
printInvalid input. Please enter a valid floating point number."
def main:
names
salaries
sentinel 'DONE'
printEnter employee names and salaries. Type 'DONE' when finished."
while True:
name inputEnter employee name or DONE to finish:
if name sentinel:
break
salary validatefloatinputEnter employee salary in thousands eg for :
names.appendname
salaries.appendsalary
if lensalaries:
printNo valid employee data entered."
return
averagesalary sumsalaries lensalaries
printf
Average Salary: $averagesalary :f
print
Employees with salaries within $ of the average:"
withinrange False
for name, salary in zipnames salaries:
if abssalary averagesalary:
printfName: name Salary: $salary :f
withinrange True
if not withinrange:
printNo employees have salaries within $ of the average."
if namemain:
main
The code above prints out the average salary and also those within a range of it So I almost have it but the last thing I need is to display every entered employee and their salary added under the text Employee and Salary Entered.
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