The user needs a program to interact with employee records.  The kinds of interactions are "Add an Employee" (Create record), "Show All Employees" (Read records), "View an Employee" (Read one record), "Update an Employee" (Update or change a record), and "Delete an Employee" (Delete a record).  These interactions form the standard data processes in much of business software Create, Read, Update, and Delete, which are known by the acronym CRUD. The user needs to continue working with records until they are ready to tell the program.  To do this, the program will present a menu of CRUD options and an option to Quit.  The user will choose an option and the program will react accordingly. For this lab, the program will only print out which option the user chose.  In later labs, we will add more functionality. Questions: What are the inputs needed to solve this programming problem (names and data types)? What are the desired outputs (data types and descriptions)? Since this is a menu of options, what do we do if the user enters something not on our list? What are the formats for the outputs?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Follow the instructions from your instructor to accomplish the following in-class lab assignment.

The Problem to Solve:

The user needs a program to interact with employee records.  The kinds of interactions are "Add an Employee" (Create record), "Show All Employees" (Read records), "View an Employee" (Read one record), "Update an Employee" (Update or change a record), and "Delete an Employee" (Delete a record).  These interactions form the standard data processes in much of business software Create, Read, Update, and Delete, which are known by the acronym CRUD.

The user needs to continue working with records until they are ready to tell the program.  To do this, the program will present a menu of CRUD options and an option to Quit.  The user will choose an option and the program will react accordingly.

For this lab, the program will only print out which option the user chose.  In later labs, we will add more functionality.

Questions:

  • What are the inputs needed to solve this programming problem (names and data types)?
  • What are the desired outputs (data types and descriptions)?
  • Since this is a menu of options, what do we do if the user enters something not on our list?
  • What are the formats for the outputs?

The Python Program

  1. Create an new Python file called employee_program.py.  Open the file in your Python editor environment.  Copy your Python program template into this new file.
  2. In the file, change the program title to "EMPLOYEE PROGRAM".  Save and run the file to make sure that it displays the title and the Program Complete message.  It is always a good idea to run your incomplete program whenever it gets to a runnable state so you can fix errors as early as possible.
  3. Print the menu title and the menu options.  Note that there is a tab escape sequence at the beginning of each of the menu lines.
    1. "\t-- Main Menu --"
    2. "\t1) Add an Employee"
    3. "\t2) Show All Employees"
    4. "\t3) View an Employee"
    5. "\t4) Update an Employee"
    6. "\t5) Delete an Employee"
    7. "\tQ) Quit"
  4. Get the choice from the user and save the string to a variable called user_choice
  5. Build the decision structure where each if or elif checks if the user_choice is equal to the strings 1, 2, 3, 4, 5, Q, or q.  For each match, print a message stating that the user chose to -- and the name of the task.  This is the part that will be changed drastically in future programs.
  6. Add an else clause to the decision structure to handle the user entering something that was not on the list.  For the body of the else, print a message stating that the choice was not recognized and ask that the user try again.
  7. Add an input statement asking the user to "Press the Enter key to continue... ".  There is no need to store this input() to a variable because we are only interested in whether the user pressed Enter.
  8. Print that the program is complete

Questions:

  • What are the inputs needed to solve this programming problem (names and data types)?
  • What are the desired outputs (data types and descriptions)?
  • What are the formats for the outputs?

The Python Program

Start with your program from last week's lab called employee_program.py.  If that program did not work, it is going to be a lot harder to move forward.

Note that is is often better to make a copy of your program before making major changes.  That way, if something goes terribly wrong, you can delete the messed up version and go back to the original to start all over.  Professional programmers use version control software such as git or Subversion to handle these sorts of tasks.

  1. Open your employee_program.py file in your editor.
  2. In the main() function, after the code that shows the program title, create a variable called "done" and set it to False.
  3. Under the variable done, create a variable called "prompt" and set it equal to "Your choice: "
  4. Under this, start the while statement with the condition "not done" -- remember the colon at the end
  5. Highlight all of the code below the while statement and above the "Program Complete" part and tab that in one tab.  This will move the code so it is considered part of the code block of the while loop
  6. In the if-elif-else structure, find the elif for the option Q.  Under the print() statement, add a line that says done = True.  This changes the loop variable to end the while loop.
  7. Save your file and run the program.  Try different menu options and a few items that are no on the menu.  Except for when you enter Q or q, the program should display a message about which item you chose, ask you to press Enter to continue, and then display the menu again.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY