- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int sum=0;
- int x,y,o,buy,corn;
- string s[]={"珍珠奶茶","茉莉綠茶","泡沫紅茶","菊花茶","多多綠茶","梅子可樂","檸檬愛玉"};
- int m[]={50,35,20,30,35,25,45};
- int z[]={0,0,0,0,0,0,0};
- cout<<"☆★☆清薪飲料店☆★☆"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0;i<7;i++)
- {
- cout<<"("<<i+1<<")"<<s[i]<<"\t"<<m[i]<<"元"<<endl;
- }
- cout<<"(8)結帳"<<endl<<endl;
- while(true)
- {
- cout<<"請輸入商品代碼: ";
- cin>>x;
- if(x==8)
- break;
- cout<<"數量: ";
- cin>>y;
- z[x-1]+=y;
- sum+=m[x-1]*y;
- }cout<<endl;
- cout<<"[購物清單]"<<endl;
- cout<<"---------------------"<<endl;
- for(int i=0;i<7;i++)
- {
- if(z[i]!=0)
- cout<<s[i]<<"\t"<<z[i]<<"元 * "<<z[i]<<"個"<<endl;
- }
- cout<<"---------------------";
-
- cout<<endl<<"共"<<sum<<"元!"<<endl<<endl;
- cout<<"1=正確無誤 2=重新選購 ";
- cin>>o;
- if(o==1)
- {
- cout<<"請付帳:";
- cin>>buy;
- corn=buy-sum;
- if(corn<0)
- {
- cout<<"錢不夠喔,還差"<<sum-buy<<"元"<<endl;
- }else if(corn==0)
- {
- cout<<"剛剛好,謝謝惠顧"<<endl;
- }else
- {
- cout<<"找您"<<corn<<"元"<<endl;
- if(corn>=500)
- {
- cout<<"五百元鈔票"<<corn/500<<"張"<<endl;
- corn=corn%500;
- }
- if(corn>=100)
- {
- cout<<"一百元鈔票"<<corn/100<<"張"<<endl;
- corn=corn%100;
- }
- if(corn>=10)
- {
- cout<<"五十元硬幣"<<corn/50<<"枚"<<endl;
- corn=corn%50;
- }
- if(corn>=10)
- {
- cout<<"十元硬幣"<<corn/10<<"枚"<<endl;
- corn=corn%10;
- }
- if(corn>=1)
- {
- cout<<"一元硬幣"<<corn/1<<"枚"<<endl;
-
- }
- }
-
- }else
- {
- goto re;
- }
- system("pause");
- return 0;
- }
複製代碼 |