Phone directory - adding data

timer Asked: Nov 11th, 2013
account_balance_wallet $50

Question Description

In this chapter, we create independent programs that are closely associated with each other. All the programs are components of a phone directory program. The intention is that you can continue your programming exercises by programming a phone directory. The exercises in this chapter can easily be converted into functions for a larger entity.

The name and number data for the phone directory are contained in the file "phonedir.txt" which has the following format:

Firstname Lastname 050-3500980
John Doe 041-3478924
Brian Smith 040-3980982
Brita Smith 05-4567393

The first line of the file indicates the number of names added to the directory as an integer. The first name, last name and telephone number are processed in text format. The data items are separated by spaces in the file, and the length of an individual item (such as a first name) may be no more than 20 characters. Each line includes the information for one person only. The directory may contain a maximum of 50 people. Your first task is to write a program for adding a new telephone number to the directory. Upon execution, the program must first ask for a first name, after which it prompts for a last name and a telephone number. When data is saved, the value on the first line of the file must increase by one. Note that in order to simplify the exercise, the data to be entered may not include a newline character, for example. Each personal data item is stored on its own line. (Remember the newline character.) Example output

Enter first name:John
Enter last name:Example
Enter telephone number:123-4567890
Successfully saved the data.

Tutor Answer

School: UC Berkeley

flag Report DMCA

awesome work thanks

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors