Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

11.8 Program: Employee Database(IN PYTHON) Human Resources has contracted you to write an employee database program for them. Since the company is small, their database

11.8 Program: Employee Database(IN PYTHON)

Human Resources has contracted you to write an employee database program for them. Since the company is small, their database will exist in a text file. They would like to use a CSV file so they can easily view the database in other programs, such as Microsoft Excel.

Write a menu-driven program that supports two functions -- the ability to add an employee and the ability to view all employees. When adding a new employee, you should get the employees name, department, and salary. The salary should be inputted as a floating point datatype.

When the program first starts, it should ask for the location of the database. That database file will then be used by all other functions of the program (e.g. adding employee and viewing employees). Your program should consist of 4 functions:

main(): This is the main function of the program. It should prompt the user for a db file location then continously display the menu and respond to the choice appropriately. For example, if the user chooses menu option 1 then the add_employee() function should be called. This process should continue until the user chooses option 3 (i.e. Exit).

menu(): This function should display the menu to the user and ask for a menu choice until a valid one is inputted. Lastly, it should return the choice as an integer.

add_employee(db): This function should input an employee's name, department, and salary from the user. Using that data, it will then open the db file in append mode and write a new row containing the employees data.

view_employees(db): This function should open the db file in read-only mode and then parse the employee data to match the sample execution below.

File path to database: employee.db

1. Add Employee

2. View Employees

3. Exit

Choice: 1

Employee name: Bob Smith

Department: Engineering

Salary: 52000.50

1. Add Employee

2. View Employees

3. Exit

Choice: 4

Choice: 5

Choice: 1

Employee name: Alice Jones

Department: Sales

Salary: 34535.21

1. Add Employee

2. View Employees

3. Exit

Choice: 2

Employee: Bob Smith

Department: Engineering

Salary: $52000.50

Employee: Alice Jones

Department: Sales

Salary: $34535.21

1. Add Employee

2. View Employees

3. Exit

Choice: 3

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

Step: 3

blur-text-image

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago