Can someone please help me with this in C programming. Thankyou!
——— Project 9 ———–
request.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define ROOM_LEN 100
#define NAME_LEN 30
#define PHONE_LEN 15
#include “request.h”
#include “readline.h”
struct request* append_to_list(struct request *list){
struct request *nreq = (struct request*)malloc(sizeof(structrequest));
struct request *tlist;
//getting new request details
printf(“Enter the class room: “);
read_line(nreq->classroom, ROOM_LEN);
printf(“Enter the first name: “);
read_line(nreq->first, NAME_LEN);
printf(“Enter the last name : “);
read_line(nreq->last, NAME_LEN);
//To detect if any entry is duplicate
tlist = list;
while(tlist != NULL){
if(strcmp(tlist->classroom, nreq->classroom) == 0)
if(strcmp(tlist->first, nreq->first) == 0)
if(strcmp(tlist->last, nreq->last) == 0){
printf(“%s %s is already on the waiting list for %s class. Toupdate details, enter operation code: un”,list->first,list->last, list->classroom );
//delete nreq;
return list;
}
tlist = tlist->next;
}
printf(“Enter phone number : “);
read_line(nreq->phone, PHONE_LEN);
nreq->next = NULL;
if(list == NULL){
return nreq;
}
tlist = list;
while(tlist->next != NULL)
tlist = tlist->next;
tlist->next = nreq;
return list;
}
//function to update a child details
void update(struct request *list){
char classroom[ROOM_LEN];
char first[NAME_LEN + 1];
char last[NAME_LEN + 1];
struct request *tlist;
if(list == NULL){
printf(“List is enpty.n”);
return;
}
//asking details
printf(“Enter the class room: “);
read_line(classroom, ROOM_LEN);
printf(“Enter the first name: “);
read_line(first, NAME_LEN);
printf(“Enter the last name : “);
read_line(last, NAME_LEN);
tlist = list;
while(tlist != NULL){
if(strcmp(tlist->classroom, classroom) == 0)
if(strcmp(tlist->first, first) == 0)
if(strcmp(tlist->last, last) == 0){
printf(“Enter the new class room: “);
read_line(tlist->classroom, ROOM_LEN);
return;
}
tlist = tlist->next;
}
// if nothing is found
printf(“%s %swas not found on the waiting list for %sclassroom.n”, first, last, classroom);
}
void printList(struct request *list){
printf(“Classroom First Name Last Name Contact Phone”);
while(list != NULL){
printf(“n%s”, list->classroom);
printf(” %s %s”, list->first, list->last);
printf(” %s”, list->phone);
list = list->next;
if(list != NULL)
printf(“n”);
}
}
void clearList(struct request *list)
{
if(list == NULL) {
return;
}
clearList(list->next);
free(list);
}
request.h
#ifndef request_h
#define request_h
#define ROOM_LEN 100
#define NAME_LEN 30
#define PHONE_LEN 15
struct request{
char classroom[ROOM_LEN];
char first[NAME_LEN + 1];
char last[NAME_LEN + 1];
char phone[PHONE_LEN + 1];
struct request *next;
};
//function prototypes
struct request* append_to_list(struct request *list);
void update(struct request *list);
void printList(struct request *list);
void clearList(struct request *list);
int read_line(char Str[], int n);
#endif
readline.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include”readline.h”
int read_line(char Str[], int n){
int ch, i = 0;
while(isspace(ch = getchar()));
Str[i++] = ch;
while((ch = getchar()) != ‘n’){
if(i < n)
Str[i++] = ch;
}
Str[i] = ‘ ‘;
return i;
}
readline.h
#ifndef read_lineh
#define read_lineh
#define NAME_LEN 30
int read_line(char Str[], int n);
#endif
waiting_list.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include”readline.h”
#include”request.h”
int main(void)
{
char code;
struct request *wait_list = NULL;
printf(“Operation Code: a for appending to the list, u for updatinga book” “, p for printing the list; q for quit.n”);
for(;;){
//getting operation code
printf(“nEnter operation code: “);
scanf(“%c”, &code);
while(getchar() != ‘n’); // skips to end of line
//checking operation code
switch(code){
//append operation
case ‘a’: wait_list = append_to_list(wait_list);
break;
case ‘u’: update(wait_list);
break;
case ‘p’: printList(wait_list);
break;
case ‘q’: clearList(wait_list);
return 0;
default: printf(“Illegal coden”); //Invalid operation code
}
printf(“n”);
}
}
makefile
all: waiting_list
waiting_list: readline.o request.owaiting_list.o
gcc readline.o request.o waiting_list.o -owaiting_list
waiting_list: waiting_list.c
gcc waiting_list.c -o waiting_list.o
request: request.c
gcc request.c -o request.o
readline: readline.c
gcc readline.c -o readline.o
Project 10, Program Design 1. (70 points) Modify project 9 by adding and modifying the following functions: 1) Add a delete function in request.c that delete a book. The function should delete a request from the list by room number and person’s first and last name. Room number and name will be entered by the user. The function should have the following prototype: struct request* delete from list (struct request *list); You will also need to add the function prototype to the header file; modify the main function in laundry list.c to add ‘d’ for delete option in the menu and it calls the delete function when the ‘d’ option is selected. 2) Modify the append to list function so a request is inserted into an ordered list (by last name and first name) and the list remains ordered after the insertion. For example, a request by Ashley Meyers should be before a request by Justin Winn in the list; a request by Elizabeth Lewis should be after a book by Ashely Lewis in the list. The order of the requests does not matter if multiple requests have the same names. Show transcribed image text Project 10, Program Design 1. (70 points) Modify project 9 by adding and modifying the following functions: 1) Add a delete function in request.c that delete a book. The function should delete a request from the list by room number and person’s first and last name. Room number and name will be entered by the user. The function should have the following prototype: struct request* delete from list (struct request *list); You will also need to add the function prototype to the header file; modify the main function in laundry list.c to add ‘d’ for delete option in the menu and it calls the delete function when the ‘d’ option is selected. 2) Modify the append to list function so a request is inserted into an ordered list (by last name and first name) and the list remains ordered after the insertion. For example, a request by Ashley Meyers should be before a request by Justin Winn in the list; a request by Elizabeth Lewis should be after a book by Ashely Lewis in the list. The order of the requests does not matter if multiple requests have the same names.
Expert Answer
Answer to Can someone please help me with this in C programming. Thank you! ——— Project 9 ———– request.c #include #in…