- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int price[]={1240,136,2584,251,987,654};
- int a,b,sum=0,pay,money;
- cout<<"***歡樂屋***"<<endl;
- cout<<"商品價目表"<<endl;
- cout<<"(1)一日喪命散\t\t1240元"<<endl;
- cout<<"(2)含笑半步癲\t\t136元"<<endl;
- cout<<"(3)地獄一日遊\t\t2584元"<<endl;
- cout<<"(4)地獄拔舌體驗卷\t251元"<<endl;
- cout<<"(5)爬劍山體驗卷\t\t987元"<<endl;
- cout<<"(6)棺材訂做\t\t654元"<<endl;
- cout<<"死亡一概不負責,消費滿5000送棺材乙個!!(限量 鍍金市價10000元)"<<endl;
- cout<<"選購完時代號都輸入8即可進入結帳頁"<<endl;
- start:
- cout<<"請輸入商品代號:"<<endl;
- cin>>a;
- if(a==8)
- {
- goto end;
- }
- cout<<"請輸入數量:"<<endl;
- cin>>b;
- if(a>=1 && a<=7 && b>0)
- {
- sum=sum+price[a-1]*b;
- goto start;
- }else
- {
- cout<<"輸入錯誤"<<endl;
- goto start
- }
- end:
- cout<<endl<<"總共"<<sum<<"元!"<<endl;
- if(sum>=5000)
- {
- cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
- }
- cout<<"請輸入付了多少錢: ";
- cin>>pay;
- money=pay-sum;
- if(money==0)
- {
- cout<<"錢剛剛好! 請慢走!"<<endl;
- }
- if(money<0)
- {
- cout<<"錢不夠! 還欠"<<-money<<endl;
- }
- if(money>0)
- {
- cout<<"總共需要找客人"<<money<<"元";
- if(money>=500)
- {
- cout<<"500元鈔票"<<money/500<<"張"<<endl;
- money=money%500;
- }
- if(money>=100)
- {
- cout<<"100元鈔票"<<money/100<<"張"<<endl;
- money=money%100;
- }
- if(money>=50)
- {
- cout<<"50元硬幣"<<money/50<<"枚"<<endl;
- money=money%50;
- }
- if(money>=10)
- {
- cout<<"10元硬幣"<<money/10<<"枚"<<endl;
- money=money%10;
- }
- if(money>=5)
- {
- cout<<"5元硬幣"<<money/5<<"枚"<<endl;
- money=money%5;
- }
- if(money>=1)
- {
- cout<<"1元硬幣"<<money/1<<"枚"<<endl;
- money=money%1;
- }
- }
-
-
- system("pause");
- return 0;
- }
複製代碼 |