Menu

(Solved) : Guys Pls Help Need C Programming Laundrylistc Include Include Include Include Include Read Q37237315 . . .

Can you guys pls help me with this? Need in C programming.

(70 points) Modify project 9 by adding and modifying the following functions 1) Add a delete function in request. c that delelaundry_list.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include”readline.h”
#include”request.h”

/**********************************************************
* main: Prompts the user to enter an operation code, *
* then calls a function to perform the requested *
* action. Repeats until the user enters the *
* command ‘q’. Prints an error message if the user *
* enters an illegal code. *
**********************************************************/

int main(void)
{
char code;

struct request *new_list = NULL;
printf(“Operation Code: a for appending to the list, u for updatinga request”
“, p for printing the list; q for quit.n”);
for (;;) {
printf(“Enter operation code: “);
scanf(” %c”, &code);
while (getchar() != ‘n’) /* skips to end of line */
;
switch (code) {
case ‘a’: new_list = append_to_list(new_list);
break;
case ‘u’: update(new_list);
break;
case ‘p’: printList(new_list);
break;
case ‘q’: clearList(new_list);
return 0;
default: printf(“Illegal coden”);
} //terminate the loop using break statement
printf(“n”);
}
}

request.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define NAME_LEN 30
#include”request.h”
#include”readline.h”

struct request *append_to_list(struct request *list){
int room_number;

printf(“Enter room number: “);
scanf(“%d”, &room_number);
while (getchar() != ‘n’);

struct request *ptr = list;
if(list != NULL) {
do {
if(ptr->room_number == room_number)
{
printf(“Request for this room already exists.To update number ofitems, enter operation code: un”);
return list;
}
if(ptr->next != NULL)
{
ptr = ptr->next;
}
} while(ptr->next != NULL);
}   
//read_line function used for reading first name, and lastname.
  
struct request *newReq = malloc(sizeof(struct request));
newReq->room_number = room_number;
  
printf(“Enter guest first name: “);
read_line(newReq->first, NAME_LEN);
  
printf(“Enter guest last name: “);
read_line(newReq->last, NAME_LEN);
  
printf(“Enter number of items: “);
scanf(“%d”, &newReq->num_items);
  
while (getchar() != ‘n’);
  
if(list == NULL)
{
list = newReq;
} else
{
ptr->next = newReq;
}
  
return list;
}

/**************************************************************
* update: Prompts the user to enter a room number, then *
* looks up items by room number in the list. Prints all the *
* information of the guest if found.Otherwise, prints amessage*
***************************************************************/

void update(struct request *list)
{
int room_number;
  
printf(“Enter room number: “);
scanf(“%d”, &room_number);

struct request *ptr = list;
while(ptr != NULL)
{
if(ptr->room_number == room_number)
{
int n;
  
printf(“Enter number of items to be added: “);
scanf(“%d”, &n);
  
while (getchar() != ‘n’);
ptr->num_items += n;
  
printf(“Room %d, number of items is updated to %dn”,room_number,ptr->num_items);
return;
}
ptr = ptr->next;
};
  
printf(“Service request is not found for room %d to add to thelist, enter operation code: a’n”, room_number);
}

void printList(struct request *list)
{   
struct request *ptr = list;
  
printf(“Room number First Name Last Name Number of items”);
while(ptr != NULL)
{
printf(“n%d”, ptr->room_number);
printf(” %s %s”, ptr->first, ptr->last);
printf(” %d”, ptr->num_items);
  
printf(“n”);
  
ptr = ptr->next;
};
}

/*****************************************************************
*clearList: clears the entire linked list. It begins at the head*
*of the list and frees memory allocated for each node of the*
*linked list. *
******************************************************************/

void clearList(struct request *list)
{
if(list == NULL) {
return;
}
  
clearList(list->next);
free(list);
}

request.h

#ifndef request_h
#define request_h
#define NAME_LEN 30

struct request{

int room_number;
char first[NAME_LEN+1];
char last[NAME_LEN+1];
int num_items;
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

(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.cto 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 (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.cto 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 you guys pls help me with this? Need in C programming. laundry_list.c #include #include #include #include #include”r…

OR