#include <stdio.h>

#define REG_HAM            2000
#define  COKE                  1000
#define MAX_ITEM           2

main()
{
             int          flag = 1;               /* flag for scanf */
             int          processing;                     /* 1 for processing, 0 for end of processing */
             int          open = 1;                          /* 1 for open, 0 for close */

             int          item_code;                      /* for menu item code */
             int          number;                           /* the number of item */

             int          no_of_item1;                    /* for one customer */
             int          no_of_item2;

             int          no_of_total_item1;            /* for daily open */
             int          no_of_total_item2;

             int          personal_total;                 /* total price for one customer */
             int          daily_total;                        /* total income */
             int          sub_total;                         /* temp total */


             no_of_total_item1 = 0;
             no_of_total_item2 = 0;
             daily_total = 0;

             while (flag == 1 && open == 1) {

                           processing = 1;
                           no_of_item1 = 0;
                           no_of_item2 = 0;
                           personal_total = 0;

                           while (flag == 1 && processing == 1) {

                                        printf("\n****************************************");
                                        printf("\n  1. Regular hamburger %15d", REG_HAM);
                                        printf("\n  2. Coke              %15d", COKE);
                                        printf("\n****************************************");
                                        printf("\n Enter the item code (0 for quit) : ");

                                        flag = scanf("%d", &item_code);

                                        if (flag == 1) {
                                                     if ((item_code > 0) && (item_code < MAX_ITEM + 1)) {
                                                                  printf(" Enter the number : ");
                                                                  flag = scanf("%d", &number);
                                                                  if (flag == 1) {
                                                                                if ((item_code == 1) && (no_of_item1 + number >= 0)) {
                                                                                             no_of_item1 = no_of_item1 + number;
                                                                                }
                                                                                else if ((item_code == 2) && (no_of_item2 + number >= 0)) {
                                                                                             no_of_item2 = no_of_item2 + number;
                                                                                }
                                                                                else {
                                                                                             printf("\n Error --- Check the number !!\n");
                                                                                }
                                                                  }
                                                                  else {
                                                                                open = 0;
                                                                  }
                                                     }
                                                     else if (item_code == 0) {
                                                                  processing = 0;
                                                     }
                                                     else {
                                                                  printf("\n Error --- Check the item code !!\n");
                                                     }
                                        }
                                        else {
                                                     open = 0;
                                        }

                           } /* while - for one customer */

                           if (no_of_item1 + no_of_item2)       {

                                        printf("\n----------------------------------------");

                                        if (no_of_item1 > 0) {
                                                     sub_total = no_of_item1 * REG_HAM;
                                                     personal_total = personal_total + sub_total;

                                                     printf("\n Regular Hamberger : %2d %14d", no_of_item1, sub_total);
                                                     no_of_total_item1 = no_of_total_item1 + no_of_item1;
                                        }
                                        if (no_of_item2 > 0) {
                                                     sub_total = no_of_item2 * COKE;
                                                     personal_total = personal_total + sub_total;

                                                     printf("\n Coke :              %2d %14d", no_of_item2, sub_total);
                                                     no_of_total_item2 = no_of_total_item2 + no_of_item2;
                                        }
                                        printf("\n----------------------------------------");
                                        printf("\n TOTAL: %30d\n", personal_total);
                           } /* print a result */

             } /* while - for daily open */

             if (no_of_total_item1 + no_of_total_item2) {
                           printf("\n========================================");

                           if (no_of_total_item1 > 0) {
                                        sub_total = no_of_total_item1 * REG_HAM;
                                        daily_total = daily_total + sub_total;

                                        printf("\n Regular Hamberger : %2d %14d", no_of_total_item1, sub_total);
                           }
                           if (no_of_total_item2 > 0) {
                                        sub_total = no_of_total_item2 * COKE;
                                        daily_total = daily_total + sub_total;

                                        printf("\n Coke              : %2d %14d", no_of_total_item2, sub_total);
                           }
                           printf("\n========================================");
                           printf("\n DAILY TOTAL: %24d\n", daily_total);
             } /* print the total result of today */

             printf("\nBye\n");
}