您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > 饮料自动售货机(带C++程序和设计报告)
(C++)作业姓名:夏亮亮学号:2010040913班级:电子二班设计报告(1)《需求分析》:本程序为饮料自动售货机的程序,能实现饮料的自动销售,能起到节约人力、减少成本的目的。(2)《项目设计》:(3)《测试报告》:1、主界面:2、选择完成之后:饮料自动售货机售货机果汁类汽水类茶类结账付款橙汁冰糖雪梨苹果汁完成雪碧可乐完成绿茶冰红茶完成钱款正确钱款错误3、付款有误画面:4、正确付款画面:源代码#includeiostreamusingnamespacestd;voidkaishi();voidchalei(),qishui(),guozhi();intxuanzhe[3]={0};intxuanzhe_qishui[2]={0};intxuanzhe_chalei[2]={0};voidkaishi(){cout********************************************endl;cout**********endl;cout*****饮料自动售货机*****endl;cout**********endl;cout********************************************endl;}voidguozhi(){cout输入对应数字并按确定endl;cout---------------------------------------------------endl;cout-------1.橙汁(单价3元)2.桃汁(单价2.5元)--------endl;cout-------3.冰糖雪梨(单价4元)4.完成----------------endl;cout---------------------------------------------------endl;}voidqishui(){cout输入对应数字并按确定endl;cout---------------------------------------------------endl;cout-------1.雪碧(单价3元)2.可乐(单价3元)----endl;cout-------3.完成------------endl;cout---------------------------------------------------endl;}voidchalei(){cout输入对应数字并按确定endl;cout---------------------------------------------------endl;cout-------1.绿茶(单价2.5元)2.冰红茶(单价3元)-----------endl;cout-------3.完成------------endl;cout---------------------------------------------------endl;}classyinliao{public:yinliao();voidxuanz_qishui();voidxuanz_chalei();voidshuqian();voidadd();voidxuanz();voidprint();protected:intsum;//总钱数};yinliao::yinliao(){sum=0;}voidyinliao::xuanz_qishui(){intp;inti;for(i=0;i4;i++){cout;cinp;if(p==3)//当输入3的时候,返回主页{break;}else{xuanzhe_qishui[i]=p;}}}voidyinliao::xuanz_chalei(){intq;inti;for(i=0;i4;i++){cout;cinq;if(q==3)//当输入3的时候,返回主页{break;}else{xuanzhe_chalei[i]=q;}}}voidyinliao::xuanz(){inti;intn;for(i=0;i4;i++){cout;cinn;if(n==4){break;}else{xuanzhe[i]=n;}}}voidyinliao::print(){intm;intj=0;intk=0;intq=0;cout您选择的为:endl;for(m=0;m4;m++){if(xuanzhe[j]==0){break;}else{switch(xuanzhe[j++]){case1:cout**橙汁**endl;break;case2:cout**桃汁**endl;break;case3:cout**冰糖雪梨**endl;break;case4:cout**苹果汁**endl;break;}}}for(m=0;m3;m++)//对点过的饮品进行打印{if(xuanzhe_qishui[k]==0){break;}else{switch(xuanzhe_qishui[k++]){case1:cout**雪碧**endl;break;case2:cout**可乐**endl;break;}}}for(m=0;m3;m++){if(xuanzhe_chalei[q]==0){break;}else{switch(xuanzhe_chalei[q++]){case1:cout**绿茶**endl;break;case2:cout**冰红茶**endl;break;}}}}voidyinliao::add()//计算总钱数{inta;intj=0;intk=0;intq=0;for(a=0;a4;a++){if(xuanzhe[j]==0){break;}else{switch(xuanzhe[j++]){case1:sum=sum+3;break;case2:sum=sum+2.5;break;case3:sum=sum+4;break;case4:sum=sum+2.5;break;}}}for(a=0;a2;a++){if(xuanzhe_qishui[k]==0){break;}else{switch(xuanzhe_qishui[k++]){case1:sum=sum+3;break;case2:sum=sum+3;break;}}}for(a=0;a2;a++){if(xuanzhe_chalei[q]==0){break;}else{switch(xuanzhe_chalei[q++]){case1:sum=sum+2.5;break;case2:sum=sum+3;break;}}}cout总钱数为:sum元endl;}voidyinliao::shuqian(){intmoney;while(1){cout请输入钱数并按确定endl;cout;cinmoney;if(money=sum){break;}else{cout;cout您输入的钱数有误,请重新输入endl;}}cout;cout您输入的钱数为:money元,找零money-sum元endl;}intmain(){yinliaoyl;intw;kaishi();while(1){coutendl请选择...endl;cout----------------------------------------------endl;cout------1.果汁类2.汽水类3.茶类4.结账付款----endl;cout----------------------------------------------endl;cout输入对应数字并按确定endl;cout;cinw;switch(w){case1:guozhi();yl.xuanz();break;case2:qishui();yl.xuanz_qishui();break;case3:chalei();yl.xuanz_chalei();break;case4:yl.print();yl.add();gotofk;}}fk:yl.shuqian();cout^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^endl;cout^^^^^^^^^^endl;cout^^^^^欢迎再次光临!^^^^^endl;cout^^^^^^^^^^endl;cout^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^endl;system(pause);return0;}
本文标题:饮料自动售货机(带C++程序和设计报告)
链接地址:https://www.777doc.com/doc-5889485 .html