- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int price[]={10000,5000,50000,4444,10,1744,55,10000};
- int h, q, pay, money,sum=0;
- cout<<"以諾豪華九星級飯店"<<endl;
- cout<<"[飯店房間價目表]"<<endl;
- cout<<"(1)四人套房\t10000元"<<endl;
- cout<<"(2)兩人套房\t5000元"<<endl;
- cout<<"(3)七人小木屋\t50000元"<<endl;
- cout<<"(4)孤單一人房\t4444元"<<endl;
- cout<<"(5)百人總統房\t10元"<<endl;
- cout<<"(6)安靈病房\t1744元"<<endl;
- cout<<"(7)太平間地下房\t55元"<<endl;
- cout<<"(8)跟泳鱔一夜情套房\t1元"<<endl;
- cout<<"[付費說明]"<<endl;
- cout<<"把要住的房間代號輸入後,再輸入要買幾間"<<endl;
- cout<<"購買完請輸入9前往結帳"<<endl;
- start:
- cout<<"請輸入商品代碼: ";
- cin>>h;
- if(h==9)
- {
- goto checkout;
- }
- else if(h>=1 && h<=8)
- {
- cout<<"請輸入購買數量: ";
- cin>>q;
- if(q>0)
- {
- sum=sum+price[h-1]*q;
- goto start;
- }
- else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }
- }
- else
- {
- cout<<"什麼年紀了還會輸入錯誤!!"<<endl;
- goto start;
- }
- checkout:
- cout<<"總共是"<<sum<<"元"<<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;
- }
- }
- system("pause");
- return 0;
- }
複製代碼 |