Question
Write a C program that creates a linked list of Customer data. Each entry in the list is to have the customers last name, first
Write a C program that creates a linked list of Customer data. Each entry in the list is to have the customers last name, first name, id (int), balance (float), and a pointer to the next customer data. Create a struct for the Customer first. Then create a pointer (head) that points to the first element in the linked list (initially NULL), as a global variable. Also, you need to create the following functions: int insertAtIndex(char * lastname, char * firstname, int id, float balance, int index) - This function attemps to insert a new customer data into the linked list using the parameter values lastname, firstname, id, and balance at the location indicated by the parameber index. If index is 0, then that means that it should be inserted as the first data in the linked list. If it is successfully inserted, then it should return the index of where it is inserted. If the parameter index value is not within the linked list size (for instance, less than 0, or greater than the index of the end data in the list.), then it should return -1. int size() - This function returns the number of entries in the linked list. If the linked list is empty, it should return 0. void displayLinkedList( ) - It prints all entries in the linked list in the following format: Last Name: Clinton
First Name: Hillary
Customer ID: 555555
Customer Balance: $ 3456.00
Last Name: Obama
First Name: Barack
Customer ID: 5
Customer Balance: $ 300.00 int removeCustomer(int id) - This function searches a customer with the parameter id, removes the customer entry, and returns the index of where that entry was located. It should return -1 if such customer entry with the given id was not found. The first customer in the linked list with the id should be removed if there are two such customer entries. struct Customer * searchCustomer(int id) - This function searches a customer entry with the parameter id, and returns that customer entry once it is found. It should return NULL if not found. int main() - The main function should start by displaying this menu in this format: Choice\t\t Action
------\t\t ------
A\t\t Add Customer
D\t\t Display List Size
P\t\t Print List Elements
R\t\t Remove Customer
S\t\t Search Customer
Q\t\t Quit
? \t\t Display Help Next, the following prompt should be displayed: What action would you like to perform? Read in the user input and execute the appropriate command. After the execution of each command, redisplay the prompt. Commands should be accepted in both lowercase and uppercase. The following describes what needs to be done for each command. A Add Customer Your program should display the following prompt: Please enter a customer to add: Please enter the last name: Read in the customers last name. Then prompt the following: Please enter the first name: Read in the customers first name. Then prompt the following: Please enter the id(number): Read in the customers id. Then prompt the following: Please enter the balance: Read in the customers balance. Then prompt the following: Please enter the index to insert: Read in the index. Then attempt to insert the customer entry with those information at the given index. If the insertion is not successful, then display the message: The customer could not be added If the insertion is successful, then display the message: The customer is added at 2 where 2 is the index where it was added. D Display List Size Your program should display the following message: The size of the linked list is 5 where 5 is the number of entries in the linked list. P Print List Elements Each customer information in the customer list should be displayed in the following format: Last Name: Obama
First Name: Barack
Customer ID: 5
Customer Balance: $ 300.00
If there is no customer entry in the linked list, display: The list is empty
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started