Jump to content

Welcome to NulledBlog
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

Source C Asm


  • This topic is locked This topic is locked
No replies to this topic

#1
koa001

  • Offline
  • New Member

  • PipPip
  • Posts:
    24
    Reputation:
    14
    Joined:
    02 Sep, 2015

#include <stdio.h>
#include "customer.h"
#include "drink.h"
#include "iohandler.h"
#include "mileage.h"

 

extern void add_drink(int n);
extern void modif_drink(int n);

extern void get_safe_money();//자판기 금고의 돈을 출력
extern void get_customer_money();// 고객이 지불한 돈을 출력
extern void add_customer_money(int n);//고객이 돈을 지불하는 함수
extern void add_safe_money(int n);//금고의 돈을 입금하는 함수
extern void clear_safe_money();//돈을 전부 출금하는 함수

extern void load_money();
extern void load_igredient();
extern void load_customer();
extern void load_drink();

extern void save_money();
extern void save_igredient();
extern void save_mileage();
extern void save_drink();

extern void add_box_espresso(double n);
extern void add_box_va_syrup(double n);
extern void add_box_ca_syrup(double n);
extern void add_box_milk(double n);
extern void add_box_cream(double n);
extern void add_box_water(double n);

extern void set_box_espresso(double n);
extern void set_box_va_syrup(double n);
extern void set_box_ca_syrup(double n);
extern void set_box_milk(double n);
extern void set_box_cream(double n);
extern void set_box_water(double n);
extern void get_all_ingredient();

extern int search_customer(char *str);

extern void add_customer_mileage(int a);
extern void use_customer_mileage(int a, int B);

int main()
{
 

 extern struct drink drink[6];
 extern struct customer customer[100];
 extern int safe_money;
 extern int customer_money;

 extern double box_espresso;
 extern double box_va_syrup;
 extern double box_ca_syrup;
 extern double box_milk;
 extern double box_cream;
 extern double box_water;

 int choice_menu = 1;
 int administer_menu = 0;
 int return_menu = 0;
 int ingredient_menu = 0;
 double amount_ingredient = 0;
 int choice_drink = 0;

 int customer_choice = 0;
 int mileage_choice = 0;
 int use_mileage = 0;
 int customer_num = 0;
 int insert_money = 0;
 char customer_name[100];
 int drink_sale[6];
 int rank[6];
 int total_sale=0;

 FILE *customer_in;
 FILE *drink_in;
 FILE *money_in;
 FILE *ingredient_in;

 load_customer(customer_in);
 load_drink(drink_in);
 load_igredient(ingredient_in);
 load_money(money_in);

 for (int i =0; i < 6; i++)
 {
  add_drink(i);
 }

 while (1)
 {
  printf(" ******************************  \n");
  printf(" * 1.고객 모드                *  \n");
  printf(" * 2.관리자 모드              *  \n");
  printf(" ******************************  \n");
  printf("메뉴를 선택하시오.");
  scanf("%d", &choice_menu);

  while (choice_menu)
  {
   if (choice_menu == 1) // 고객모드
   {
    system("cls");
    printf(" **********   **********   **********  \n");
    printf(" *  %c    *   *  %c    *   *  %c    *  \n", drink[0].name, drink[1].name, drink[2].name);
    printf(" *        *   *        *   *        *  \n");
    printf(" *  %d   *    *  %d    *   *  %d    *  \n", drink[0].cost, drink[1].cost, drink[2].cost);
    printf(" **********   **********   **********  \n");
    printf("    (1)          (2)          (3)  \n");
    printf("\n");
    printf(" **********   **********   **********  \n");
    printf(" *  %c    *   *  %c    *   *  %c    *  \n", drink[3].name, drink[4].name, drink[5].name);
    printf(" *        *   *        *   *        *  \n");
    printf(" *  %d   *    *  %d    *   *  %d    *  \n", drink[3].cost, drink[4].cost, drink[5].cost);
    printf(" **********   **********   **********  \n");
    printf("    (4)          (5)          (6)  \n");
    printf("\n");
    printf("고객모드입니다. 메뉴로 돌아가려면 -1을 입력하세요 : ");
    scanf("%d", &return_menu);

    if (return_menu == -1) // 메뉴로 돌아감
    {
     return_menu = 0;
     break;
     
    }
    printf("회원이십니까?<예:1,아니오:2>");
    scanf("%d", &customer_choice);
    if (customer_choice == 1)
    {
     printf("\n성함을 입력하십시오");
     scanf("%s", &customer_name);

     customer_num = search_customer(customer_name);
     if (customer_num !=0)
     {
      printf("\n%s님 현재 마일리지는 %d입니다", customer_name, customer[customer_num].mileage);
      if (customer[customer_num].mileage > 2000)
      {
       printf("마일리지가 2000점이 넘습니다 사용하시겠습니까?<예:1, 아니요:2>");
       scanf("%d", mileage_choice);
       if (mileage_choice == 1)
       {
        printf("얼마를 사용하시겠습니까?");
        scanf("%d", use_mileage);
        use_customer_mileage(customer_num, use_mileage);
        customer_money += use_mileage;
       }
      }
     }
    }

    printf("\n투입금액을 입력하십시오");
    scanf("%d", insert_money);
    customer_money += insert_money;

    printf("\n음료를 선택하세요.");
    scanf("%d", &choice_drink);

    switch (choice_drink)
    {
    case 1:
     if (customer_money < drink[0].cost)
     {
      printf("\n금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[0].cost;
     
     set_box_espresso(drink[0].espresso);
     set_box_va_syrup(drink[0].va_syrup);
     set_box_ca_syrup(drink[0].ca_syrup);
     set_box_milk(drink[0].milk);
     set_box_cream(drink[0].cream);
     set_box_water(drink[0].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }
     break;

    case 2:
     if (customer_money < drink[1].cost)
     {
      printf("금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[1].cost;

     set_box_espresso(drink[1].espresso);
     set_box_va_syrup(drink[1].va_syrup);
     set_box_ca_syrup(drink[1].ca_syrup);
     set_box_milk(drink[1].milk);
     set_box_cream(drink[1].cream);
     set_box_water(drink[1].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }

     break;

    case 3:
     if (customer_money < drink[2].cost)
     {
      printf("금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[2].cost;
     
     set_box_espresso(drink[2].espresso);
     set_box_va_syrup(drink[2].va_syrup);
     set_box_ca_syrup(drink[2].ca_syrup);
     set_box_milk(drink[2].milk);
     set_box_cream(drink[2].cream);
     set_box_water(drink[2].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }

     break;

    case 4:
     if (customer_money < drink[3].cost)
     {
      printf("금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[3].cost;

     set_box_espresso(drink[3].espresso);
     set_box_va_syrup(drink[3].va_syrup);
     set_box_ca_syrup(drink[3].ca_syrup);
     set_box_milk(drink[3].milk);
     set_box_cream(drink[3].cream);
     set_box_water(drink[3].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }

     break;

    case 5:
     if (customer_money < drink[4].cost)
     {
      printf("금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[4].cost;

     set_box_espresso(drink[4].espresso);
     set_box_va_syrup(drink[4].va_syrup);
     set_box_ca_syrup(drink[4].ca_syrup);
     set_box_milk(drink[4].milk);
     set_box_cream(drink[4].cream);
     set_box_water(drink[4].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }

     break;

    case 6:
     if (customer_money < drink[5].cost)
     {
      printf("금액이 부족합니다.\n");
      break;
     }
     customer_money -= drink[5].cost;

     set_box_espresso(drink[5].espresso);
     set_box_va_syrup(drink[5].va_syrup);
     set_box_ca_syrup(drink[5].ca_syrup);
     set_box_milk(drink[5].milk);
     set_box_cream(drink[5].cream);
     set_box_water(drink[5].water);

     if (customer_choice == 1)
     {
      add_customer_mileage(customer_num);
     }

     break;
    }

    printf("잔액을 받으시려면 0을 입력하시고 계속하시려면 다른숫자를 입력하세요.");
    scanf("%d", &choice_drink);
    if (choice_drink == 0)
    {
     printf("잔액 %d가 나왔습니다. 안녕히 가세요", customer_money);
     customer_money = 0;
     choice_drink = 0;
    }
   }
   else if (choice_menu == 2) // 관리자 모드
   {
    printf("-----------관리자메뉴입니다----------\n");
    printf("-----------1.재료추가----------\n");
    printf("-----------2.메뉴변경----------\n");
    printf("-----------3.금고----------\n");
    printf("-----------4.매출----------\n");
    printf("-----------5.선호도조사----------\n");
    printf("관리자 모드입니다. 메뉴로 돌아가려면 -1을 입력하세요 : ");
    scanf_s("%d", &return_menu);

    if (return_menu == -1) // 메뉴로 돌아감
    {
     break;
    }

    printf("메뉴를 선택하세요. : ");
    scanf("%d", &administer_menu);

    switch (administer_menu)
    {
    case 1: // 재료추가

     printf("재료추가 메뉴입니다.추가할 재료를 선택하세요 전단계로 돌라가려면 -1을 눌러주세요");
     get_all_ingredient();
     printf("1.에스프레소\n");
     printf("2.바닐라시럽\n");
     printf("3.카라멜시럽\n");
     printf("4.크림\n");
     printf("5.우유\n");
     printf("6.물\n");
     scanf("%d", &ingredient_menu);

     switch (ingredient_menu)

     {
     case 1:
      printf("에스프레소입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_espresso(amount_ingredient);
      break;
     case 2:
      printf("바닐라시럽 입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_va_syrup(amount_ingredient);
      break;
     case 3:
      printf("카라멜시럽입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_ca_syrup(amount_ingredient);
      break;
     case 4:
      printf("크림입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_cream(amount_ingredient);
      break;
     case 5:
      printf("우유입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_milk(amount_ingredient);
      break;
     case 6:
      printf("물입니다 얼마를 더 넣겠습니까?\n");
      scanf("%lf", &amount_ingredient);
      add_box_water(amount_ingredient);
      break;

     default:
      break;
     }

   
     break;

    case 2: // 메뉴변경

     printf("메뉴변경입니다.변경할 음료번호를 선택하세요 전단계로 돌라가려면 -1을 눌러주세요");
     scanf("%d", &choice_drink);
     modif_drink(choice_drink);

     break;

    case 3: // 금고

     get_safe_money();
     printf("출금하시겠습니까?<예:1,아니오:2>");
     scanf("%d", &choice_menu);
     if (choice_menu == 1)
     {
      clear_safe_money();
      printf("거스름돈을 위해 얼마를 입금하시겠습니까?");
      scanf("%d", &insert_money);
      add_safe_money(insert_money);
     }
     else
     {
      break;
     }
     break;

    case 4: // 매출

     
     for (int i = 0; i<6; i++)
     {
      drink_sale[i] = drink[i].cost*drink[i].sell_count;//팔린 횟수*가격
     }
     printf("음료                판매금액\n");
     for (int j = 0; j<6; j++)
     {
      printf("%s                 %d \n", drink[j].name, drink_sale[j]);//음료당 매출
      total_sale += drink_sale[j];
     }
     printf("총매출:               %d\n", total_sale);//총매출

     break;

    case 5: // 선호도 조사

     
     for (int i = 0; i < 6; i++)
     {
      rank[i] = 1;
      for (int j = 0; j < 6; j++)
      {
       if (drink[i].sell_count < drink[j].sell_count)
       {
        rank[i]++;  //자신보다 높은 점수가 있으면서 순위를 1증가
        {
        }
       }
       printf("음료                선호도순위\n");
       for (i = 0; i < 6; i++)
       {
        printf("%s                 %d \n", drink[i].name, rank[i]);
       }
      }
     }
     break;
   }
    
   }
  }
 }
}


  • 1


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users