Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to read and process customer records (data about a customer) Each customer record must be stored in a struct that contains

Write a C 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, followed by a space.

Address. Entered by the user as four comma-seperated values (max of 94 characters long), followed by a space. The address data must be stored as separate values, as follows:

Street address and numbers (max 55 chars)

City name (Max 32 chars).

Two-character state abbreviation

Zipcode (5-digit number). You should process it as character data, not a number.

Account_Balance. A floating-point number that represents the outstanding balance owed by the customer.

You may assume that customer records will always be entered using the format described above, i.e., name address balance. Not 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). Your program must contain a function that replaces all dashes in string data with a space.

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.

A struct should by dynamically allocated for each new customer as its read, and the new struct should be linked into the list in the proper position.The program must continue processing customer records and/or commands until the user enters QUIT to exit the program. The program must support the following set of commands, entered via standard input:

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

LISTREVERSE: Shows the list of customers in reverse order.

INSERT 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 the list must be kept in alphabetical order(ascending) by customer name.

DELETE removes a customer record from the list and displays the following message:

RECORD DELETED

or

RECORD NOT FOUND

EDIT

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.

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

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 are not case sensitive. You must hve 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. All magic numbers that you use, if any, must be defined as preprocessor macros.

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_2

Step: 3

blur-text-image_3

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions