bighomew.cpp

来自「VC6.0小型图书馆管理程序。建议具有书籍存储与信息检索、借阅者信息存储与检索、」· C++ 代码 · 共 1,009 行 · 第 1/3 页

CPP
1,009
字号
/* 
  ************************************
    大作业内容:8-9超市帐务管理程序
    文件名:BIGHOMEW.cpp
    日期:2004-12-6
    作者:结43班 王宁 
    学号:2004010158
    电话:51533409
    Email:oop-tyler@163.com 
  ************************************
*/


/*
  加载头文件
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <graphics.h>

/*
  该结构体定义的是库存商品的信息:
  包括名称、批发价、零售价、进货价、库存量、售出量、序号、商品利润、销量、营业额。
*/
struct goods
{
 char name[50];
 float wholesaleprice;
 float singlesaleprice;
 float inprice;
 int inquantity;
 int outquantity;
 int serial;
 float acc;
 int sellnum;
 float selltur;
};


/*
  初始化12个商品信息
*/
struct goods goo[30]=
{
 {"Jordan's Sock",50.1,85.0,14.5,100,34,1,0.0,0,0.0},
 {"Pretty Cola",2.0,2.5,1.0,1000,2445,2,0.0,0,0.0},
 {"The Music (CD)",75.0,100.0,43.5,780,248,3,56.5,1,100.0},
 {"The Haha Peas",2.3,3.0,1.7,580,401,4,6.5,5,15.0},
 {"Dream Bags",230.7,280.0,150.0,250,64,5,0.0,0,0.0},
 {"The big Piano",3670.0,4230.0,3121.5,120,13,6,0.0,0,0.0},
 {"<Horse Riding>",34.0,40.0,27.5,2000,1096,7,0.0,0,0.0},
 {"Star War (Game)",20.5,35.5,12.8,13,249,8,44.4,2,71.0},
 {"China Green Tea",50.0,65.4,35.9,127,237,9,0.0,0,0.0},
 {"Times' Stamps",1.2,1.8,0.7,91,999,10,0.0,0,0.0},
 {"FLCQuick PC",6478.0,7892.0,4502.0,400,189,11,0.0,0,0.0},
 {"Tyler's Works",10000.0,19850.0,9449.0,4,1,12,0.0,0,0.0},
};

/*
  该结构体定义的是顾客所购买的商品的信息:
  包括商品名称、售出价格、购买数量、消费额、商品进货价。
*/
struct bgoods
{
 char name[50];
 float price;
 int num;
 float cost;
 float inprice;
};

/*
  该结构体定义的是顾客所的购买信息:
  包括购物小票编号、购物日期、总消费、购买商品、购买商品种数。
*/
struct buy
{
 int listnum;
 char date[10];
 float totalcost;
 struct bgoods goo[20];
 int goonum;
};

/*
  初始化2个购物信息
*/
struct buy buy[20]=
{
 {1002,"04-11-16",100.0,{"The Music (CD)",100.0,1,100.0,43.5},1},
 {1003,"04-10-27",86.0,{{"The Haha Peas",3.0,5,15.0,1.7},
		        {"Star War (Game)",35.5,2,71.0,12.8}},2}
};

/*
  定义两个static型全局变量分别表示购物次数和总商品数
*/
static int buynum=2;
static int count=12;

/*
  各函数声明
*/
void main();                           /*主函数*/
void Welcome();                        /*打印欢迎信息*/
void Mainmenu();                       /*打印主菜单*/
void Shpmenu();     		       /*打印购物菜单*/
void Mngmenu();     		       /*打印管理菜单*/
void Goodsmanagementmenu();            /*打印商品管理菜单*/
int Getchoice1();     		       /*菜单选择函数*/
int Getchoice2();   		       /*菜单选择函数*/
int Getchoice3();   		       /*菜单选择函数*/
int Getchoice4();    		       /*菜单选择函数*/
void Shpmode();       		       /*购物菜单*/
void Mngmode();     		       /*商品管理菜单*/
void Goodsbrowse1();      	       /*商品浏览(顾客)*/
void Goodsbrowse2();                   /*商品浏览(管理员)*/
void Goodschoose();                    /*购物过程函数*/
void Shopinquiry();                    /*购买记录查询*/
void Undoshopping();                   /*退货处理*/
void Goodsmanagement();                /*商品管理*/
void Addgoods();                       /*添加新商品*/
void Delgoods();                       /*删除商品*/
void Searchgoods();                    /*查询商品信息*/
void Modifygoods();                    /*修改商品信息*/
void Caltc();                          /*统计总营业额和总利润*/
void Calgoodstc();                     /*统计各商品利润及其在总利润中的比例*/
void Goodssort();                      /*商品排序(按销量和营业额)*/
void Storagemanagement();              /*库存管理*/


/*
  Function: main()
  Description: 主函数
  Returns: None
*/
void main()
{
 //int graphDriver=DETECT;             /*加载图形模式*/
 //int graphMode;
 //initgraph(&graphDriver,&graphMode,"d:\\tc\\bgi");

 int select1;
 select1=0;
 while (select1!=3)
 {
  clrscr();
  Welcome();
  Mainmenu();
  select1=Getchoice1();
  switch (select1)
  {
   case 1:Shpmode();break;
   case 2:Mngmode();break;
   case 3:exit(0);break;               /*强制退出*/
   default :break;
  }
 }
}

/*
  Function: Welcome()
  Description: 打印欢迎信息
  Returns: None
*/
void Welcome()
{
 textbackground(BLUE);
 textcolor(YELLOW);
 printf("\t\t***  Welcome to The Scopio Store!  ***\n");
 printf("This is a progromm that help you to go shopping(also management).\n");
 printf("\n");
}

/*
  Function: Mainmenu()
  Description: 打印主菜单
  Returns: None
*/
void Mainmenu()
{
 printf("         **********Main Menu*********!\n\n");
 printf("1.Shopping Mode!\n");
 printf("2.Management Mode!\n");
 printf("3.Quit!\n");
}

/*
  Function: Shpmenu()
  Description: 打印购物菜单
  Returns: None
*/
void Shpmenu()
{
 printf("         **********Shopping Mode Menu*********!\n\n");
 printf("1.Goods Browse!\n");
 printf("2.Do The Shopping!\n");
 printf("3.Inquir Your Shopping Record!\n");
 printf("4.Undo The Shopping!\n");
 printf("5.Main Menu!\n");
}
/*
  Function: Mngmenu()
  Description: 打印管理菜单
  Returns: None
*/
void Mngmenu()
{
 printf("         **********Management Mode Menu*********!\n\n");
 printf("1.Goods Management!\n");
 printf("2.Calculate Turnover&Account!\n");
 printf("3.Calculate Goods's Turnover&Account!\n");
 printf("4.Goods Sort!\n");
 printf("5.Storage Management!\n");
 printf("6.Main Menu!\n");
}

/*
  Function: Goodsmanagementmenu()
  Description: 打印商品管理菜单
  Returns: None
*/
void Goodsmanagementmenu()
{
 printf("         **********Goods Management Menu*********!\n\n");
 printf("1.Goods Browse For Management!\n");
 printf("2.Add New Goods!\n");
 printf("3.Delete Goods!\n");
 printf("4.Search Goods!\n");
 printf("5.Modify Goods!\n");
 printf("6.Management Mode Menu!\n");
}

/*
  Function: Getchoice1()
  Description: 菜单选择函数
  Returns: 用户输入的整数值
*/
int Getchoice1()
{
 int select1;
 select1=0;
 printf("Please input your choice: (Press the key 1 to 3)");
 fflush (stdin);
 scanf("%d",&select1);
 return select1;
}

/*
  Function: Getchoice2()
  Description: 菜单选择函数
  Returns: 用户输入的整数值
*/
int Getchoice2()
{
 int select2;
 select2=0;
 printf("Please input your choice: (Press the key 1 to 5)");
 fflush (stdin);
 scanf("%d",&select2);
 return select2;
}

/*
  Function: Getchoice3()
  Description: 菜单选择函数
  Returns: 用户输入的整数值
*/
int Getchoice3()
{
 int select3;
 select3=0;
 printf("Please input your choice: (Press the key 1 to 6)");
 fflush (stdin);
 scanf("%d",&select3);
 return select3;
}

/*
  Function: Getchoice4()
  Description: 菜单选择函数
  Returns: 用户输入的整数值
*/
int Getchoice4()
{
 int select4;
 select4=0;
 printf("Please input your choice: (Press the key 1 to 6)");
 fflush (stdin);
 scanf("%d",&select4);
 return select4;
}

/*
  Function: Shpmode()
  Description: 购物菜单
  Returns: None
*/
void Shpmode()
{
 int select2;
 select2=0;
 while (select2!=5)
 {
  clrscr();
  Shpmenu();
  select2=Getchoice2();
  switch (select2)               /*用户输入选择进入各函数实现菜单功能*/
  {
   case 1:Goodsbrowse1();break;
   case 2:Goodschoose();break;
   case 3:Shopinquiry();break;
   case 4:Undoshopping();break;
   case 5:main();break;
   default :break;
  }
 }
}

/*
  Function: Mngmode()
  Description: 商品管理菜单
  Returns: None
*/
void Mngmode()
{
 int select3;
 select3=0;
 while (select3!=6)
 {
  clrscr();
  Mngmenu();
  select3=Getchoice3();
  switch (select3)              /*用户输入选择进入各函数实现菜单功能*/
  {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?