1. Implement a program to read and process customer records (data about a customer). Each customer record must be stored in a struct that contains the following fields:

  • Full_Name (all alphabetic, max of 40 characters long). Includes first, middle, and last name and is followed by a space.
  • Account_Balance. A floating-point number that represents the outstanding balance owed by the customer.
  • Address. Entered by the user as four comma-separated values (max of 94 characters long), followed by a space. The address data must be stored as separate values, as follows:
    • Street address and number (max 55 chars)
    • City name (max 32 chars).
    • Two-character state abbreviation
    • Zip code (5-digit number). You should process it as character data, not a number

You may assume that customer records will always be entered using the format described above, i.e., name address balance. Note the spaces in between.

Important: Customer names, city names, and street addresses may contain spaces; however, because scanf stops reading data as soon as it finds whitespace, users will enter a dash (-) wherever a space would go in the input (see sample runs). The program must contain a function that replaces all dashes in string data with a space.

2. The number of customers is not known in advance and your program cannot ask the user how many there are. You need to use a linked list to store the customer data. The list must be kept sorted in alphabetical order, ascending based on the customers name.

3. A struct should be dynamically allocated for each new customer as it is read, and the new struct should be linked into the list in the proper position

4. The program must continue processing customer records and/or commands until the user enters "QUIT" to exit the program.

5. The program must support the following set of commands, entered via standard input:

a. LIST
Prints the list of customers in ascending name order, using the format specifier "%s\n%s\n%s, %2s %5s\n%9.2f\n-----\n" for name, street address, city, state, zip, and balance respectively.

b. INSERT < customer information as described above>
Inserts a new customer record into the list and displays the following message:

RECORD INSERTED
or
DUPLICATE RECORD
if a record with the same name is already in the list.

Note that the list should be kept in alphabetical order (ascending), by customer name.

c. DELETE < customer name> removes a customer record from the list and displays the following message:

RECORD DELETED
or
RECORD NOT FOUND

d. EDIT < customer information as described above>
Edits an existing customer record already in the list, i.e., replaces the current information with the new information. Also, displays the following message:

RECORD EDITED
or
RECORD NOT FOUND

NOTE: Because the name field is used as the primary key, it cannot be edited. (See http://databases.about.com/cs/administration/g/primarykey.htm for more information about primary keys).

e. CALCBALANCE: Calculates and displays the total balance owed by all customers. The value shown is the sum of the customer balances for all the customers on the list. The following format specifier must be used: "TOTAL BALANCE $%.2f\n"

f. HELP
Displays the set of available commands, as shown below (must match exactly).

Commands:
LIST - Shows the list of customers
LISTREVERSE - Shows the list of customers in reverse order
INSERT - Creates a new customer record
DELETE - Deletes an existing customer record
EDIT - Modifies the contents of a customer record
CALCBALANCE - Calculates and displays the total balance
HELP - Displays the set of available commands
QUIT – Prints the message "Good bye!" and exits the program

6. All the command input is case sensitive, i.e., input that follows DELETE and EDIT must match the case of the records on the list, otherwise they are considered different records. Note that commands (e.g LIST) are not case sensitive.

7. You may assume that all the input that follows a valid command is free of errors, i.e., all customer data entered by the user follows the specified format.

8. You must have separate functions to handle each one of the commands listed above. The functions must provide a significant procedural decomposition of the program into meaningful parts. That means your functions should not be trivial just to meet the design instructions.

9. All "magic numbers" that you use, if any, must be defined as preprocessor macros.

10. Implement the LISTREVERSE command, which prints the list of customers in descending order by name.

Sample Input and Output

Some sample runs are provided below. User input is in bold and blue.

Sample #1

Enter command:
Quit
==========
Good bye!

Sample #2

Enter command:
quit
==========
Good bye!

Sample #3

Enter command:
INSERT Jane NoStreet,Raleigh,NC,27615 25000
========== RECORD INSERTED Enter command:
INSERT John-Doe 123-Any-Street,Winston-Salem,NC,28269 25000.95
========== RECORD INSERTED Enter command:
INSERT Peter-Pan Neverland-Ave-Apt.12,Asheville,NC,12345 50000
========== RECORD INSERTED Enter command: list
========== Jane NoStreet
Raleigh, NC 27615
25000.00
----- John Doe
123 Any Street
Winston Salem, NC 28269
25000.95
----- Peter Pan
Neverland Ave Apt.12
Asheville, NC 12345
50000.00
-----
Enter command:
LISTREVERSE
========== Peter Pan
Neverland Ave Apt.12
Asheville, NC 12345
50000.00
----- John Doe
123 Any Street
Winston Salem, NC 28269
25000.95
----- Jane NoStreet
Raleigh, NC 27615
25000.00
-----
Enter command:
INSERT Charles Some-Avenue,Chicago,IL,60290 42000
========== RECORD INSERTED Enter command:
INSERT Morpheous Some-Avenue,Chicago,IL,60290 18000
========== RECORD INSERTED Enter command: LIST
==========
Charles
Some Avenue
Chicago, IL 60290
42000.00
----- Jane NoStreet
Raleigh, NC 27615
25000.00
----- John Doe
123 Any Street
Winston Salem, NC 28269
25000.95
----- Morpheous Some Avenue
Chicago, IL 60290
18000.00
----- Peter Pan
Neverland Ave Apt.12
Asheville, NC 12345
50000.00
-----
Enter command:
DELETE John
==========
RECORD NOT FOUND Enter command: DELETE jane
==========
RECORD NOT FOUND Enter command: DELETE Peter-Pan
========== RECORD DELETED Enter command: list
========== Charles
Some Avenue
Chicago, IL 60290
42000.00
----- Jane NoStreet
Raleigh, NC 27615
25000.00
----- John Doe
123 Any Street
Winston Salem, NC 28269
25000.95
----- Morpheous Some Avenue
Chicago, IL 60290
18000.00
-----
Enter command:
EDIT Jane Western-Blvd.,Raleigh,NC,27615 35000
========== RECORD EDITED Enter command:
EDIT Jim Western-Blvd.,Raleigh,NC,27615 25000
==========
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.