Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.09 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. float getBun()
  4. {
  5.     /* Chilli submarine-C
  6.     Hotdog-D
  7.     Swarma-S
  8.     Burger-B*/
  9.     char bun;
  10.     float value;
  11.     printf("Enter your prefed bun: ");
  12.     scanf("%c", &bun);
  13.  
  14.     if ((bun = 'c') || (bun = 'C'))
  15.         printf("Rs. each\n");
  16.     else if ((bun = 'd') || ('D'))
  17.         printf("Rs. each\n");
  18.     else if ((bun = 's') || ('S'))
  19.         printf("Rs. each\n");
  20.     else if ((bun = 'b') || ('B'))
  21.         printf("Rs. each\n");
  22.     else
  23.         printf("invalid code\n");
  24.     return value;
  25. }
  26. int getQuantity()
  27. {
  28.     int qty;
  29.     printf("Enter your required quantity: ");
  30.     scanf("%i", &qty);
  31.     return qty;
  32. }
  33. float getDistence()
  34. {
  35.     float dis;
  36.     printf("Enter your distance to the store from your home in Km: ");
  37.     scanf("%f", &dis);
  38.     getchar();
  39.     if (dis <= 1)
  40.         printf("Your deleviary is free\n");
  41.     else if (dis <= 4)
  42.         printf("Your deleviary fee=100/=\n");
  43.     else if (dis > 4)
  44.         printf("Your deleviary fee=200/=\n");
  45.     return dis;
  46. }
  47.  
  48. int main()
  49. {
  50.     float dis;
  51.     int n = 0, m = 0;
  52.     char answer;
  53.     printf("Do you want to order another bun (Y/N): ");
  54.     scanf("%c", &answer);
  55.     if (n == 12)
  56.     {
  57.         printf("You reached the limit");
  58.         dis = getDistence();
  59.     }
  60.     else
  61.     {
  62.         while (m < 1)
  63.         {
  64.             if (answer == 'n' || answer == 'N')
  65.             {
  66.                 dis = getDistence();
  67.                 m++;
  68.             }
  69.             else if (answer == 'y' || answer == 'Y')
  70.             {
  71.                 getchar();
  72.                 char _bun = getBun();
  73.                 getchar();
  74.                 int _qty = getQuantity();
  75.                 n++;
  76.                 getchar();
  77.                 printf("Do you want to order another bun (Y/N): ");
  78.                 scanf("%c", &answer);
  79.             }
  80.             else
  81.             {
  82.                 printf("Wrong input!!\n");
  83.                 getchar();
  84.                 printf("Do you want to order another bun (Y/N): ");
  85.                 scanf("%c", &answer);
  86.             }
  87.         }
  88.     }
  89.     return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement