Program: 88
The policy followed by a company to process customer orders is given by the following rules:
(i) If order quantity is less than or equal to that in stock and his credit is ok, supply his requirement.
(ii) If his credit is not ok do not supply. Send him intimation.
(iii) if his credit is ok but the item in stock is less than his order, supply what is in stock. Intimation him that balance will be shipped later.
Write a C program to implement the company policy.
#include<stdio.h> int main() { //Suppose we have only 100 product (Quantity of product) in stock int stock=100, order; char credit; printf("Enter the customer order: "); scanf("%d", &order); //check for customer credit printf("Is his credit is ok? (Press y/n)\n"); credit = getch(); //it receive only one character //check for rule (i) if(order<=stock && credit == 'y' || credit == 'Y') //user may enter capital letter also printf("Sir,\n\t We supplied your requirement\n\t\t Quantity: %d",order); //check for rule (ii) else if(order>stock && credit == 'y' || credit == 'Y') printf("Sir,\n\t We supplied %d products and balance will be shipped later.",stock); //check for rule (iii) else printf("Sir,\n\t Please first clear your credit, until we can't supply you any more."); }
Output:
Enter the customer order: 90 Is his credit is ok? (Press y/n) Sir, We supplied your requirement Quantity: 90 Enter the customer order: 200 Is his credit is ok? (Press y/n) Sir, We supplied 100 products and balance will be shipped later. Enter the customer order: 50 Is his credit is ok? (Press y/n) Sir, Please first clear your credit, until we can't supply you any more.
Leave a Comment