Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

apply all the concepts you learned in previous weeks and apply the use of sequential input and output operations to add two new functionalities to

apply all the concepts you learned in previous weeks and apply the use of sequential input and output operations to add two new functionalities to your Employee Management System.

  • Export employees' information to text file: This functionality will allow the user to save the employee information saved in the list to the file system. Each list entry should be saved into a new line. You may notice by now that closing the script will cost your Employee Management System to lose all entered employees' information. Exporting the current system data into a file system will help you to save this information permanently on the hard disk and be able to use it at later time.
  • Import employees' information from text file: This functionality will help you to import preexisting employee information from a text file saved on the file system. Each line in the text should be saved as a new list entry. When you run your Employee Management System for the first time you should be able to populate the system with preexisting employee information, if there are any, instead of adding this information manually to the system.

Python Version 3 on a Mac

Here is my script, I keep getting an error the top part is what I just added the rest of the code works without it.

mployees = []

count = 0

def export():#method that stores the employee data to a file

f = open("employeedata.txt", "w")

for i in employees:

f.write(i[0]+" "+str(i[1])+" "+str(i[2])+" "+str(i[3])+" "+str(i[4])+" ")#write each employee data to file

f.close()

# method that imports data from file to list

file = open("employees.txt", "r")

l = list(file.readiness())

for i in range(len(l)):

l[i] = l[i][:-1]

for i in l:

t = i.split("") # stores each employee data to list

employees.append(t)

def Add_Employee():

global count

Employee=[]

count+=1

print('Enter name of employee:',end='')

Employee.append(input())

print('Enter employee SSN:',end='')

Employee.append(input())

print('Enter employee phone number:',end='')

Employee.append(input())

print('Enter employee email:',end='')

Employee.append(input())

print('Enter employee salary:',end='')

Employee.append(input())

employees.append(Employee)

def view_all_Employees():

for i in employees:

print("---------------------------- "+i[0]+" -----------------------------")

print('SSN:',i[1])

print('Phone:',i[2])

print('Email:',i[3])

print('Salary:',i[4])

print("------------------------------------------------------------------------")

def search_Employee(ssn):

findIdex=0

for i in employees:

if(i[1]==ssn):

return findIdex

findIdex+=1

return -1

while(True):

print('Enter -1 to exit')

print('Enter 1 to add employee')

print('Enter 2 to view all employees')

print("Enter 3 to search employee with SSN")

print("Enter 4 to update employee information")

a=int(input())

if(a==-1):

break

elif(a==1):

Add_Employee()

print()

elif(a==2):

view_all_Employees()

print()

elif(a==3):

ssn=input("Enter the SSN number to find employee: ")

empIndex=search_Employee(ssn)

if(empIndex>=0):

print("---------------------------- "+employees[empIndex][0]+" -----------------------------")

print('SSN:',employees[empIndex][1])

print('Phone:',employees[empIndex][2])

print('Email:',employees[empIndex][3])

print('Salary:',employees[empIndex][4])

print("------------------------------------------------------------------------ ")

else:

print("Employee with "+ssn+" is not found. ")

elif(a==4):

ssn=input("Enter the SSN number to update employee: ")

empIndex=search_Employee(ssn)

if(empIndex>=0):

employees[empIndex][0]=input("Ente updated name: ")

employees[empIndex][2]=input("Enter updated phone number: ")

employees[empIndex][3]=input("Enter updated email address: ")

employees[empIndex][4]=input("Enter updated salary: ")

print("Employee information has been updated successfully. ")

else:

print("Employee with "+ssn+" is not found. ")

else:

print('invalid output')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

1 Explain company-wide strategic planning and its four steps.

Answered: 1 week ago