Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Description Your work at the fleet vehicle startup has been going well. You now

ID: 3592486 • Letter: D

Question

Description Your work at the fleet vehicle startup has been going well. You now have a few customers, and one of their requests is that they want your software to keep track of the deliveries they need to make, and they want to use the software to decide which delivery to send out first. Your job is to write a command line interface that can keep track of these deliveries. Your program will be given a series of com mands as input. The commands your program should accept are the following: order, delivery, exit exit When the command "exi" is given, your program should exit. You should make sure to clean up any allocated memory before exiting. order If your program is given the command "order", that means an or der is being inputted to your program. Your program then needs to read an order ID, followed by a product name, followed by a quantity. The order ID and the quantity are integers. The product name is a string that is guaranteed to be less than 20 characters.

Explanation / Answer

Ihis is the program for the above question, have a look and give ur feedback to us!!1

My Program:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct order // structure for product linked list
{
   int orderId,quantity;
   char product[20];
     struct order *next;
};

struct order typedef ord;
ord* root=NULL; // pointer for root node
ord* last=NULL; // pointer always points to the last node
ord* current=NULL; //pointer always point to the current new node
int main()
{
void order();
void delivery();
int del=0;
char cmd[100]; // array for command , max 100
int i=1;
printf("enter the command ");
   do{
  
   scanf("%s",cmd);
   if(cmd[0]=='o')
   order();
   else if(cmd[0]=='d')
   del++;
   else if(cmd[0]=='e') // case to handle exit command
       {   while(1){
     
           if(del==0)
            exit(0);
           else
           {
            while(del)
           {
           delivery();
           del--;
            }
            }
        }
       }
   else
   printf("enter appropriate command: order,delivery,exit ");
    }while(i);
   return 1;
}

void order() // function to handle order command
{
  
   current=(ord*)malloc(sizeof(ord));
   scanf("%d%s%d",&current->orderId,&current->product,&current->quantity);
   current->next=NULL;
   if(root == NULL)
   {
   root=current;
   last=current;
   }
   else
   {
   last->next=current;
   last=current;
   }

}

void delivery()   // function to handle delivery command
{
   if(root!=NULL)
   {
   printf("%d%s%d ",root->orderId,root->product,root->quantity);
   ord *temp=root;
   root=root->next;
   free(temp);
    }
else
printf("No product to deliver ");
  
}