Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming Help - Please! **LinkedList Help Address book program receives commands from the standard input. The commands allow the user to add, edit, sort

C Programming Help - Please!

**LinkedList Help

Address book program receives commands from the standard input. The commands allow the user to add, edit, sort and delete contacts, as well as load or save contacts from/to a file. Each contact has a first name, last name, email address, and phone number.

Write a program that:

Prints "Ready " to the stdout.

While the quit command('q') has not been received:

Receives a command from the standard input (do not print a prompt, just get the command) and executes the command. Each command consists of a command code on one line, plus one or more parameters, each on a separate line. Each command code is a single character. The list of commands and associated parameters is given below: 1. Add a new contact: Code: a

First parameter: 0-based index where the new contact should be inserted. 0 would mean in front of the first contact in the list, 1 would mean in front of the second contact in the list, and so on. This value will not be greater than the current number of contacts in the address book.

Second parameter: String containing a comma delimited list of contact property values. The order is last_name, first_name, email, phone_number

Example: a 1 SMITH,AUNDREA,asmith@ign.com,8001110001

2. Delete a contact: Code: d

First parameter: 0-based index of the contact to delete. NOTE: if the index is higher than the number of contacts - 1, do nothing.

Example: d 1

3. Get a contact: Code: g

First parameter: 0-based index of the contact.

Example: g 1 Output to stdout: The value of the requested field, terminated with a . E.g. "WILSON,HORACE,hwilson@mayoclinic.com,8001110008 "

4. Get a field: Code: f

First parameter: 0-based index of the contact.

Second parameter: Name of the field to get. Valid values are firstName, lastName, email, phoneNumber.

Example: f 1 lastName

Output to stdout: The value of the requested field, terminated with a . E.g. "SMITH "

5. Get the number of contacts in the list: Code: n

Example: n

Output to stdout: The number of contacts in the list, terminated with a . E.g. "10 ".

6. Load a file: Code: l

First parameter: path of the file to load.

Notes: The file format is CSV. There is one header line that describes the fields, then one contact per line thereafter. The order of the contact information is the same as that of the second parameter of the add command. If the address book is not empty, this command adds the loaded contacts at the end of the current list. Here is an example file (note: if you want to see what's in this file, open it in a text editor rather than a spreadsheet program).

Example: l mycontacts.csv

7. Save the contacts to a file: Code: s

First parameter: path of the file to save to.

Notes: The file format is CSV, one contact per line. If the file already exists, it is overwritten.

Example: s mycontacts.csv

8. Quit program: Code: q

Example: q

Output to stdout: "Complete "

9. Edit a contact: Code: e

First parameter: 0-based index of the contact that is to be changed.

Second parameter: Name of the field to edit. Valid values are firstName, lastName, email, phoneNumber.

Third parameter: new value of the field.

Example: e 3 phoneNumber 8002220001

10. Sort the contacts: Code: o

Notes: Sort order is ascending based on last name, then first name, then email, then phone number.

Example: o

OTHER (1)

1. Each contact must be stored in a struct.

2. All fields of the contact can contain up to 255 characters.

3. You can assume that contact field values will not contain commas. E.g. you won't be given a first name like Au,ndrea.

4. Your program must store the contacts as an ordered list (not necessarily sorted). You can implement the list using either an array or a linked list.

5. Your source code must be split into at least two.c files and one .h file. An example would be main.c, address_book.c, address_book.h.

OTHER (2)

Sample stdin 1

a 0 WILSON,HORACE,hwilson@mayoclinic.com,8001110008 a 1 JOHNSON,ROSALIA,rjohnson@pricegrabber.com,8001110002 a 1 WILLIAMS,SACHIKO,swilliams@about.com,8001110003 g 2 q

Sample stdout 1

Ready JOHNSON,ROSALIA,rjohnson@pricegrabber.com,8001110002 Complete

Sample stdin 2

a 0 SMITH,AUNDREA,asmith@ign.com,8001110001 a 1 JOHNSON,ROSALIA,rjohnson@pricegrabber.com,8001110002 a 1 WILLIAMS,SACHIKO,swilliams@about.com,8001110003 d 1 s mycontacts.csv q

Sample stdout 2

Ready Complete

Sample Output File 2 (mycontacts.csv)

lastName,firstName,email,phoneNumber SMITH,AUNDREA,asmith@ign.com,8001110001 JOHNSON,ROSALIA,rjohnson@pricegrabber.com,8001110002

** I know this is a long program **

** I can use extra question submissions if needed **

** Need Help **

** Much appreciated **

** Will give "thumbs up" and positive comments **

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

What roles have these individuals played in your life?

Answered: 1 week ago