- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int sum=0;
- int code,qty,option,money,pay;
- string name[]={"齊爾 爆焰龍捲","卡莉 聖域福音","悟空 合金進化","夜叉 戰地之王","瑟斐斯 煉獄修羅","柯里納卡 荒漠邪翅","馬洛斯 鋼鐵戰線"};
- int price[]={15,20,24,18,30,12,60,2000};
- int count[]={0,0,0,0,0,0,0};
- cout<<"☆★☆傳說對決造型專賣店☆★☆"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0;i<7;i++)
- {
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- }
- cout<<"(8)結帳"<<endl<<endl;
- while(true)
- {
- cout<<"請輸入商品代碼:";
- cin>>code;
- if(code<1 || code>8)
- {
- cout<<"輸入錯誤!"<<endl;
- continue;
- }
- if(code==8)
- break;
- cout<<"數量:";
- cin>>qty;
- if(qty<1 || qty>999)
- {
- cout<<"輸入錯誤!"<<endl;
- continue;
- }
- count[code-1]+=qty;
- sum+=price[code-1]*qty;
- }
- cout<<"[購物清單]"<<endl;
- cout<<"------------------------"<<endl;
- for(int j=0;j<7;j++)
- {
- if(count[j]!=0)
- {
- cout<<name[j]<<"\t"<<price[j]<<"元 *"<<count[j]<<"個"<<endl;
- }
- }
- cout<<"------------------------"<<endl;
- cout<<endl<<"總共"<<sum<<"元"<<endl<<endl;
- re2:
- cout<<"1-正確無誤 2-重新選購";
- cin>>option;
- cout<<endl;
- if(option==1)
- {
- re3:
- cout<<"請付帳";
- cin>>pay;
- money=pay-sum;
- if(money>0)
- {
- cout<<"找您"<<money<<"元!"<<endl;
- if(money>=500)
- {
- cout<<"五百元鈔票"<<money/500<<"張"<<endl;
- money=money%500;
- }
- if(money>=100)
- {
- cout<<"一百元鈔票"<<money/100<<"張"<<endl;
- money=money%100;
- }
- if(money>=50)
- {
- cout<<"五十元硬幣"<<money/50<<"枚"<<endl;
- money=money%50;
- }
- if(money>=10)
- {
- cout<<"十元硬幣"<<money/10<<"枚"<<endl;
- money=money%10;
- }
- if(money>=1)
- {
- cout<<"一元硬幣"<<money/1<<"枚"<<endl;
- }
- }
- else if(money==0)
- {
- cout<<"銘謝惠顧!"<<endl;
- }else
- {
- cout<<"您付的錢不夠,還差"<<money<<"元"<<endl;
- goto re3;
- }
- }else if(option==2)
- {
- goto re;
- }else
- {
- cout<<"您輸入的代碼有誤!"<<endl;
- goto re2;
- }
- system("pause");
- return 0;
- }
-
複製代碼 |