c商品订购系统.docx

上传人:b****1 文档编号:2699256 上传时间:2023-05-04 格式:DOCX 页数:8 大小:15.39KB
下载 相关 举报
c商品订购系统.docx_第1页
第1页 / 共8页
c商品订购系统.docx_第2页
第2页 / 共8页
c商品订购系统.docx_第3页
第3页 / 共8页
c商品订购系统.docx_第4页
第4页 / 共8页
c商品订购系统.docx_第5页
第5页 / 共8页
c商品订购系统.docx_第6页
第6页 / 共8页
c商品订购系统.docx_第7页
第7页 / 共8页
c商品订购系统.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

c商品订购系统.docx

《c商品订购系统.docx》由会员分享,可在线阅读,更多相关《c商品订购系统.docx(8页珍藏版)》请在冰点文库上搜索。

c商品订购系统.docx

c商品订购系统

Documentserialnumber【UU89WT-UU98YT-UU8CB-UUUT-UUT108】

 

c商品订购系统

#include

#include

#include

#include

#include

usingnamespacestd;

voidfile_1();

voidfile_2();

intmenu1();

voidmenu2();

voidchoose(int);

voidch1();

voidch2();

voidch3();

voidch4();

voidch5();

voidch6();

classgoods

{

public:

goods(void);

goods(string,string,float,string,float,string,float=0);

~goods(void);

voiddisplay1();

voiddisplay2();

stringgetnumber();

stringgetname();

floatgetprice();

floatgetstore();

stringgetunit2();

floatgetsold();

staticvoidtotalcount(float);

staticfloatgettotal();

voidplus_reduce(float);

private:

stringnumber;

stringname;

floatprice;

stringunit1;

floatstore;

stringunit2;

floatsold;

staticfloattotal;

};

intmain()etsold()>0)isplay2();

}

}

cout<<"总计:

"<

:

gettotal()<<"元"<

=0)

{

etname()<

}

}

file2<<"合计:

"<

:

gettotal()<<"元"<

line();;

cout<<"\t\t|2.商品购买|"<

line();

cout<<"\t\t|3.查看帐单|"<

line();

cout<<"\t\t|4.确认结帐|"<

line();

cout<<"\t\t|5.退出程序|"<

line();

cout<<"\t\t请选择菜单(1~6):

";

intch;

cin>>ch;

choose(ch);

}

voidch1()isplay1();isplay1();etnumber())etstore()>1e-5)etunit2()=="台"&&fabs(m-float(int(m)))>1e-5)

{

cout<<"购买数量应为整数,请重新输入!

"<

flag=1;//改变flag值,表示已找到商品

}

}

if(!

flag)//若flag为0则未找到商品

{

cout<<"找不到该商品,请重新输入!

"<

gotoget;

}

}

back();//返回购物菜单

}

voidch3()//显示购物清单

{

if(goods:

:

gettotal()>0)

{

check();

}

else

{

cout<<"您尚未购买任何商品,是否立即购买(Y/N):

";

charyn;

cin>>yn;

if(yn=='y'||yn=='Y')

{

cout<<"即将进入购物系统!

";

system("pause");//暂停

system("cls");//清屏

ch2();//进入购物系统

}

}

back();//返回购物菜单

}

voidch4()//结算,支付函数

{

if(goods:

:

gettotal()>0)

{

cout<<"总计:

"<

:

gettotal()<<"元"<

floatn=0;

pay:

cout<<"请输入支付金额:

";//提示支付

floatm=0;

cin>>m;

n+=m;

if(goods:

:

gettotal()-n>0)//若支付金额不足,则提示不足金额,要求重新支付

{

cout<<"金额不足,还差"<

:

gettotal()-n<<"元,"<<"请继续支付!

"<

gotopay;

}

if(n-goods:

:

gettotal()>=0)//金额足够则完成支付,并找零

{

cout<<"找零"<

:

gettotal()<<"元"<

cout<<"支付完成,按任意键显示帐单!

";

system("pause");

check();

cout<<"收款"<

cout<<"找零"<

:

gettotal()<<"元"<

cout<<"谢谢惠顾,欢迎下次光临!

"<

file_2();//调用file_2,将清单存入

_exit();//退出

}

}

else

{

cout<<"您尚未购买任何商品,是否立即购买(Y/N):

";

charyn;

cin>>yn;

if(yn=='y'||yn=='Y')

{

cout<<"即将进入购物系统!

";

system("pause");//暂停

system("cls");//清屏

ch2();//进入购物系统

}

}

}

voidch5()//退出系统

{

cout<<"您是否确定退出本系统(Y/N):

";

charyn;

cin>>yn;

if(yn=='y'||yn=='Y')

{

_exit();//退出

}

else

{

back();//返回购物菜单

}

}

voidch6()//非菜单选项输入情况

{

cout<<"输入错误,请重新输入!

";

back();//返回购物菜单

}

voidchoose(intch)//将菜单选择与各函数相连接实现功能选择

{

switch(ch)

{

case1:

ch1();break;

case2:

ch2();break;

case3:

ch3();break;

case4:

ch4();break;

case5:

ch5();break;

default:

ch6();

}

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2