Computer Science, asked by kalnalni2sril, 1 year ago


Write a C Program to Implement the Company PolicyThe policy followed by a company to process customers orders is given by the following rules : (1) If order quantity is less than or equal to that in stock and his credit is okay, supply his requirement. (2) If his credit is not ok do not supply. Send him intimation. (3) If his credit is ok but the item in stock is less than his order, supply what is in stock. Intimate him that balance will be shipped later. Write a C program to implement the company policy.

Answers

Answered by kvnmurty
3
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int customerCredits[100] = {1,3, 0, 13, 100, 39, 98, 10, 33, 20, 25 };
int stockAvailable = 1000;
int creditLimit = 20;

main()
{
    int custId, orderQty, qtyToSupply;

    while ( receiveOrder(&custId,  &orderQty) {
         if (!  checkCredit(custId)) {
              sendIntimation(custId, "You have not enough credits. Sorry\n");
              continue;
         }
         qtyToSupply = stockAvailable(orderQty);
         if (! qtyToSupply) continue;

         supplyItems(custId, qtyToSupply);
         stockAvailable -= qtyToSupply;
         customerCredits[custId] += qtyToSupply ;

         if (qtyToSupply < orderQty) {
             sendIntimation(custId, "The Balance qty %d will be shipped soon..\n",orderQty - qtyToSupply);
          }
    } //while
}

int receiveOrder(int *customerId, int *quantity)
{
     *customerId = 62;  *quantity = 25;
     return TRUE;
}

int checkCredit(int customerId)
{
    if (customerCredits[customerId] < creditLimit)
              return TRUE;
    return FALSE;
}

sendIntimation(customerId, char *mesg)
{
     printf("Dear Customer %d:  %s\n",customerId, mesg);
}

int supplyItems(int customerId, int orderQty)
{
    printf("Customer %d  qty supplied\n",customerId, orderQty);
}

int stockAvailable(int orderQty)
{
     if (stockAvailable < 0)
         return FALSE;
     if (stockAvailable < orderQty)
         return stockAvailable;
     return (orderQty);
}

kvnmurty: clik on thanks. select best ans
Similar questions