Solution:
I am using the below format to store the details into the employees.dat file
ID : Name : Department : JobTitle
Look at the code , comments and Output for better understanding.......................
Screenshots of the codes:
employee.py
employee_App.py
UML Diagram:
Output:
Code to copy:
employee.py
class Employee:
def __init__(self,id,name,dep,job):
self._empid=id
self._name=name
self._department=dep
self._jobTitle=job
def getName(self):
return self._name
def getId(self):
return self._empid
def getDep(self):
return self._department
def getJob(self):
return self._jobTitle
def setName(self,name):
self._name=name
def setDep(self,dep):
self._department=dep
def setJob(self,job):
self._jobTitle=job
employee_App.py
from employee import Employee
Details={}
#Check if there is a file employee.dat already exists
flag=0
try:
file=open('employees.dat','r')
except FileNotFoundError:
flag=1
#If exists load its values into the Dictionary Details
if flag==0:
file=open('employees.dat','r')
for line in file:
temp=line.split(':')
id=temp[0]
name=temp[1]
dep=temp[2]
job=temp[3]
Details[id]=Employee(id,name,dep,job)
#Displaying the menu to the user
while True:
print("1) Look up an Employee")
print("2) Add a new Employee")
print("3) Modify Employee")
print("4) Delete an employee")
print("5) Quit")
choice=input("Enter choice: ")
if(choice=='1'):
id=input("Enter Employee Id: ")
if id in Details:
print("Employee Found")
else:
print("Employee Not Found")
elif choice=='2':
id=input("Enter Employee Id: ")
name=input("Enter Employee Name: ")
dep=input("Enter Employee Department: ")
job=input("Enter Employee Job Title: ")
Details[id]=Employee(id,name,dep,job)
elif choice=='3':
id=input("Enter Employee Id: ")
print("1) Name")
print("2) Department")
print("3) Job Title")
ch=input("Enter choice to modify: ")
if ch=='1':
name=input("Enter Name: ")
Details[id].setName(name)
elif ch=='2':
dep=input("Enter Department: ")
Details[id].setDep(dep)
elif ch=='3':
job=input("Enter Job Title: ")
Details[id].setJob(job)
else:
print("Invalid Choice")
elif choice=='4':
id=input("Enter Employee Id: ")
Details.pop(id)
print("Employee removed")
elif choice=='5':
break
else:
print("Invalid choice")
#Writing the data to the employees.dat
file=open('employees.dat','w')
for key in Details.keys():
emp=Details[key]
emp_data=key+":"+emp.getName()+":"+emp.getDep()+":"+emp.getJob()+"\n"
file.write(emp_data)
I hope this would help...............................:-))
please make sure to write down all the coding and the output for it and to...
1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present a menu that lets the user perform the following actions: ✓ Look up an employee in the dictionary ✔ Add a new...
It must be C++
Chapter 13 Programming Challenge 2: Employee Class.
See instruction: Chapter 13 Programming Challenge 2 Employee
Class.pdf
Program Template:
// Chapter 13, Programming Challenge 2: Employee Class
#include <iostream>
#include <string>
using namespace std;
// Employee Class Declaration
class Employee
{
private:
string name; // Employee's name
int idNumber; // ID number
string department; // Department name
string position; // Employee's position
public:
// TODO: Constructors
// TODO: Accessors
// TODO: Mutators
};
// Constructor #1
Employee::Employee(string...
Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...
Create a c++ code and answer number 1
Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...
Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...
Use python to create this program.
1) Employee Class Write an Employee class that keeps data attributes for the following pieces of information: Note: For all classes, the attributes must be hidden Employee Name Employee Number Hire Date Create accessors and mutators Attributes should be hidden. Create a class attribute that determines a standard pay rate adjustment 4% for raises 2) ProductionWorker Class Write a class named ProductionWorker that is a subclass of Employee that holds the following attributes .Shift...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object....
Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...