Advertisement
Mr_kindle

coupon.c

Oct 26th, 2022 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.48 KB | None | 0 0
  1. /*Siva is very busy with work and wants to order food from Zomato. He wants to order one time
  2. today, and buy three items costing X1, X2 and X3 rupees. He'll also order once tomorrow, where
  3. he'll buy three items costing Y1, Y2 and Y3 rupees. There is an additional delivery charge of
  4. rupees “A” on each order. He also notices that there is a coupon on sale, which costs
  5. rupees “C”. If he buys that coupon, the delivery charges on any day and on an order of ₹150 or
  6. more shall be waived (that is, the “A” rupees will not be added, if the sum of the costs of the
  7. items is ≥150). So Siva is ordering three items together on each day, so the delivery charge
  8. apply only once each day. Also, it's only needed to buy that coupon once to benefit the delivery
  9. fee waiver on both days. Should Siva go ahead and buy the coupon?
  10. Note that Shiva will buy the coupon only if it costs him strictly less than what it costs him
  11. without the coupon, in total.
  12. Input:
  13.  The first line of the input contains a single integer T, denoting the number of test cases.
  14.  The first line of each test case contains two space-separated integers “A” and “C”, denoting
  15. the delivery charge and price of the coupon.
  16.  The second line of each test case contains three space-separated integers X1, X2 and X3,
  17. denoting the prices of the food items to order on Day 1.
  18.  The third line of each test case contains three space-separated integers Y1, Y2 and Y3, denoting
  19. the prices of the food items to order on Day 2.
  20. Output: For each test case, output YES if Siva should buy the coupon, or NO otherwise.*/
  21. /*aLSO available on Pastebin.com*/
  22. /*Input
  23. 2
  24. 47 55
  25. 75 78 18
  26. 72 50 10
  27. 45 65
  28. 130 100 80
  29. 100 80 50
  30.  
  31. Output
  32. NO
  33. YES*/
  34.  
  35.  
  36. #include<stdio.h>
  37. #include<stdlib.h>
  38.  
  39. int main()
  40. {   int test_case,a,c,x1,x2,x3,y1,y2,y3;
  41.     int day1_sum,day2_sum;
  42.     printf("Enter number of test cases:  \n");
  43.     scanf("%d",&test_case);
  44.     while(test_case)
  45.         {
  46.             start: //jump level for goto
  47.            
  48.             if(test_case == 0)
  49.             break;
  50.  
  51.             test_case--;
  52.            
  53.             printf("\nEnter the value of 'A' & 'C' according to question: ");
  54.             scanf("%d %d",&a,&c);
  55.             printf("\nEnter price of all 3 food of day 1: \n");
  56.             scanf("%d %d %d",&x1,&x2,&x3);
  57.             printf("\nEnter price of all 3 food of day 2: \n");
  58.             scanf("%d %d %d",&y1,&y2,&y3);
  59.             day1_sum = x1+x2+x3;
  60.             day2_sum = y1+y2+y3;
  61.             if(day1_sum < 150 && day2_sum < 150)
  62.                 {
  63.                     printf("\nNO");
  64.                     goto start;
  65.                 }
  66.             else if(day1_sum >= 150 && day2_sum >= 150)
  67.                 {
  68.                     if(c < 2*a)
  69.                         {
  70.                             printf("\nYES");
  71.                             goto start;
  72.                         }
  73.                     else
  74.                         {
  75.                              printf("\nNO");
  76.                              goto start;
  77.                         }
  78.                 }
  79.             else
  80.                 {
  81.                     if(c<a)
  82.                         {
  83.                             printf("\nYES");
  84.                             goto start;
  85.                         }
  86.                     else
  87.                         {
  88.                             printf("\nNO");
  89.                             goto start;
  90.                         }
  91.                 }
  92.  
  93.         }
  94.         return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement