小型书店进销存管理系统程序实验报告
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
小型书店进销存管理系统程序实验报告#include<iostream>
#include<string>
#include<fstream>
using namespace std;
struct shu_store
{int shuhao;//书编号
string shuming;//书名
int sale_day;//销售日
int shu_amount;//进书量
double shu_price;//每本书进价
double sale_price;//每本书的售价
int sale_amount;//每本书销售量
int store_amount;//库存量
static double shu_discount;//折扣
double day_saleprice;//日销售额
double day_profit;//日盈利
}shu1;
class shu
{
public:
shu(){}//构造函数
void shu_input();//进书数据输入
void shu_add();//增书数据输入
void sell_check();//书日销售额
void month_price_check();//书月销售额
void shu_check();//查询书数据
void shu_tell();//书库存查询
void price_check();//书的财务盈利核对
void manage();//处理各函数
protected:
struct shu_store shu1;
int check_shuhao;//输入查询书号
static int sum;//月销售额
};
void shu::shu_input()//进书数据输入
{cout<<"所进购书的信息:"<<endl;
cout<<"书号:";cin>>shu1.shuhao;
cout<<"书名:";cin>>shu1.shuming;
cout<<"进书量:";cin>>shu1.shu_amount;
cout<<"书进价:";cin>>shu1.shu_price;
cout<<"书售价:";cin>>shu1.sale_price;
iofile.write((char*)&shu1,sizeof(shu_store));//写入文件
}
void shu::shu_add()//增书数据输入
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件cout<<"输入书号:";cin>>check_shuhao;
if(check_shuhao==shu1.shuhao)
{cout<<"书号:";cout<<shu1.shuhao<<endl;
cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"进书量:";cout<<shu1.shu_amount<<endl;
cout<<"书进价:";cout<<shu1.shu_price<<endl;
cout<<"书售价:";cout<<shu1.sale_price<<endl;
int stu_amount;
cout<<"增书量:";cin>>shu_amount;
shu1.shu_amount=shu_amount+shu1.shu_amount;
cout<<"更新数据:"<<endl;
cout<<"所进购书的信息:"<<endl;
cout<<"书号:";cout<<shu1.shuhao<<endl;
cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"更新后书量:";cout<<shu1.shu_amount<<endl;
cout<<"书进价:";cout<<shu1.shu_price<<endl;
cout<<"书售价:";cout<<shu1.sale_price<<endl;
iofile.write((char*)&shu1,sizeof(shu_store));//写入文件}
else
{cout<<"it is error!"<<endl;}
}
void shu::shu_check();//查询书数据
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件cout<<"输入查询的书号:";cin>>check_shuhao;
cout<<endl;
if(check_shuhao=shu1.shuhao)
{cout<<"书号:";cout<<shu1.shuhao<<endl;
cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"现在书量:";cout<<shu1.shu_amount<<endl;
cout<<"书进价:";cout<<shu1.shu_price<<endl;
cout<<"书售价:";cout<<shu1.sale_price<<endl;
}
cout<<"书销售量:";cin>>shu1.sale_amount;
cout<<"书销售日子:";cin>>shu1.sale_day;
iofile.write((char*)&shu1,sizeof(shu_store));//写入文件}
void shu::shu_tell();//书库存查询
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件cout<<"书号:";cin>>check_shuhao;
if(check_shuhao=shu1.shuhao)
{
if((shu1.shu_amount-shu1.sale_amout)>10)
{cout{cout<<"书号:";cout<<shu1.shuhao<<endl;
cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"现在书量:";cout<<shu1.shu_amount<<endl;
cout<<"书进价:";cout<<shu1.shu_price<<endl;
cout<<"书售价:";cout<<shu1.sale_price<<endl;
cout<<"书销售量:";cout<<shu1.sale_amount<<endl;
cout<<"书销售日子:";cout<<shu1.sale_day<<endl;}
else
cout<<"库存不足10本书,请补充课本;"<<endl;
}
}
else
cout<<"没有此书,请重新输入;"<<endl;
}
double shu_store::shu_discount=0.8;//折扣
void shu::sell_check()//书日销售额
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件
cout<<"输入书号:";cin>>check_shuhao;
if(check_shuhao=shu1.shuhao)
cout<<"书的销售量:";cout<<shu1.sale_amount<<endl;
static double rate=1.0;
if(shu1.sale_amount>10)rate=rate*shu1.shu_discout;
{shu1.day_saleprice=(10*shu1.sale_price)+(shu1.sale_amount-10)*rate*shu1.sale_price;} else
shu1.day_saleprice=shu1.sale_amount*shu1.sale_price;
cout<<"书的日销售额:";cout<<shu1.day_saleprice<<endl;
iofile.write((char*)&shu1,sizeof(shu_store));//写入文件
}
int shu1::sum=0;//月销售额
void shu::month_price_check()//书的月销售额
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件
cout<<"输入查询的书号:";cin>>check_shuhao;
cout<<endl;
if(check_shuhao=shu1.shuhao)
{cout<<"书号:";cout<<shu1.shuhao<<endl;
cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"现在书量:";cout<<shu1.shu_amount<<endl;
cout<<"书进价:";cout<<shu1.shu_price<<endl;
cout<<"书售价:";cout<<shu1.sale_price<<endl;
for(int i=0;i<30;i++)
{cout<<"书销售量:";cin>>shu1.sale_amount;
cout<<"书销售日子:";cin>>shu1.sale_day;
static double rate=1.0;
if(shu1.sale_amount>10)rate=rate*shu1.shu_discout;
{shu1.day_saleprice=(10*shu1.sale_price)+(shu1.sale_amount-
10)*rate*shu1.sale_price;}
else
shu1.day_saleprice=shu1.sale_amount*shu1.sale_price;
sum=sum+shu1.day_saleprice;
}
cout<<"月销售额:";cout<<sum<<endl;
}
iofile.write((char*)&shu1,sizeof(shu_store));//写入文件
}
void shu::price_check();//书的财务盈利核对
{iofile.read((char*)&shu1,sizeof(shu_store));//读出文件
cout<<"输入书号:";cin>>check_shuhao;
if(check_shuhao=shu1.shuhao)
{cout<<"书名:";cout<<shu1.shuming<<endl;
cout<<"书的销售量:";cout<<shu1.sale_amount<<endl;
cout<<"书的销售日子:";cout<<shu1.sale_day<<endl;
cout<<"书的日销售额:";cout<<shu1.day_saleprice<<endl;
shu1.day_profit=shu1.day_saleprice-shu1.sale_amount*shu1.shu_price;
cout<<"书的盈利:";cout<<shu1.day_profit<<endl;
}
else
cout<<"没有此书,请重新输入;"<<endl;
}
void shu::manage()
{shu shu2;
int number;
do
{cout<<"1.进书数据输入"<<endl;
cout<<"2.增书数据输入"<<endl;
cout<<"3.书日销售额"<<endl;
cout<<"4.书月销售额"<<endl;
cout<<"5.查询书数据"<<endl;
cout<<"6.书库存查询"<<endl;
cout<<"7.书的财务盈利核对"<<endl;
cout<<"****输入选择操作数****"<<endl;
cin>>number;
while(gets()!='\n');
switch(number)
{case1:shu2.shu_input();break;
case2:shu2.shu_add();break;
case3:shu2.sell_check();break;
case4:shu2.month_price_check();break;
case5:shu2.shu_check();break;
case6:shu_tell();break;
case7:shu2.price_check();break;
}
}while(number<=7)
}
int main()
{fstream iofile("shu1.dat",ios::init);//定义输入输出文件流对象if(!iofile)
{cerr<<"open error!"<<endl;
exit(1);
}
shu shu2;
shu2.manage();
iofile.close();
return0;
}。