Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program to construct the beginnings of a driver's license database, test the program, and examine the results. Please show the code and the

write a program to construct the

beginnings of a driver's license database, test the program, and examine the results.

Please show the code and the run the code image text in transcribed Program Specifications: The program should ultimately write to a txt file the names, ages, and hair color corresponding to attributes that are input by the user. A modular design, the program should employ several functions: . One function accepts a list of names pre-existing in the database that can be assumed to be perfect; i.e., names in the form , . That is, each pre-existing name has a capitalized last name followed by a comma, space, and a capitalized first name. The function prompts the user to input a name with that same format, but regardless of capitalization. If the name already exists in the list (ignoring capitalization), a message is printed to indicate so. Otherwise the name is added to the list with proper capitalization (possibly correcting the text input by the user). It keeps doing this until the user enters . The function returns the updated list. Example run with the pre-existing names ["Sweigart, Al", Domer, Ima", "Munsch, Charlie", "Wade, Jess"]: Enter last name, first name (blank to exit) : sweigart, al Name already in database. Enter last name, first name (blank to exit) : Kump, marty Added name to the database. Enter last name, first name (blank to exit) : In this case, the list would now contain the names ["Sweigart, Al", "Domer, Ima", "Munsch, Charlie", "Wade, Jess", "Kump, Marty"]. Notice how capitalization plays a role here. A second function inputs the updated list of names and prompts the user for each person's age and hair color, storing the ages and colors in two separate lists. The function returns these two lists. Here is an example run: Enter the age of Sweigart, Al in years: 32 Enter the hair color of Sweigart, Al: brown Enter the age of Domer, Ima in years: 18 Enter the hair color of Domer, Ima: blonde Enter the age of Munsch, Charlie in years: 77 Enter the hair color of Munsch, Charlie: gray Enter the age of Wade, Jess in years: 45 Enter the hair color of Wade, Jess: black Enter the age of Kump, Marty in years: 39 Enter the hair color of Kump, Marty: blue A third function inputs the names, ages, and hair color lists and converts the them to a single dictionary such that each name is a key with corresponding value an age-hair tuple. The function returns this dictionary, for example 'Sweigart, Al' : (32, 'brown' ) , Domer, Ima' : (18, 'blonde' ) , 'Munsch, Charlie': (77, 'gray' ) , 'Wade, Jess': (45, 'black' ) , ' Kump, Marty' : (39, 'blue' ) } . The final function accepts the data dictionary as input and writes it to a txt file called Project 2. txt. It should write the file in such a way as to have the title "Driver's License Database:" at the top, followed by two newlines. Each subsequent line has the form "Name: || Age: || Hair color: . See the attached text file as an example

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions