- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- string tag[8]={"俠盜列車手5 ","決勝時刻:黑色行動3","虹彩六號:圍突行動 ",
- "minecraft ","星際大戰:戰場前線 ","正當防衛3 ",
- "湯姆克蘭西:末日邊界","潛龍諜影:幻痛 "};
- int price[8]={2250,2250,1790,990,2500,1900,1500,2200};
- cout<<"\t※※※子耕電玩專賣店※※※"<<endl<<"本店商品保證便宜^_^"<<endl<<endl;
- cout<<"[商品一覽表]"<<endl;
- for(int i=0; i<8; i++){
- cout<<"<"<<i+1<<">"<<tag[i]<<"\t\t"<<price[i]<<"元"<<endl;
- }
- cout<<"<9>結帳去"<<"\t\t"<<endl<<endl;
- cout<<"[優惠方案]\t本店滿5000元及立刻打九折"<<endl<<endl;
- B:
- int qty[]={0,0,0,0,0,0,0,0};
- int num=0,lab,q,c, pay,coin;
- A:
- cout<<"請輸入商品代碼: ";
- cin>>lab;
- if(lab==9)
- goto checkout;
- else if(lab>=0){
- cout<<"數量: ";
- cin>>q;
- num+=price[lab-1]*q;
- qty[lab-1]+=q;
- goto A;
- }
- else{
- cout<<"輸入錯誤"<<endl;
- goto A;
- }
- checkout:
- cout<<endl<<"[購物清單]"<<endl;
- cout<<"----------------------------"<<endl;
- for(int i=0; i<=7; i++){
- if(qty[i]!=0)
- cout<<tag[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
- }
- cout<<"----------------------------"<<endl;
- cout<<endl<<"共"<<num<<"元"<<endl<<endl;
- if(num>=5000){
- cout<<"由於消費滿五千,享九折優惠!!"<<endl;
- cout<<"您只需付"<<num*0.9<<"元! 現省"<<num*0.1<<"元!"<<endl;
- num*=0.9;
- }
- cout<<"1-正確無誤 2-重新選購 ";
- cin>>c;
- if(c==2){
- cout<<endl;
- num=0;
- goto B;
- }
- else if(c==1){
- p:
- cout<<endl;
- cout<<"請您付帳: ";
- cin>>pay;
- if(pay<num&&pay>0){
- cout<<"您付的錢不夠,還差"<<num-pay<<"元"<<endl;
- goto p;
- }
- else if(pay<=0){
- cout<<"奧客,請付錢"<<endl;
- goto p;
- }
- else{
- coin=pay-num;
- cout<<endl<<"感謝,找您"<<coin<<"元!"<<endl;
- if(coin>=1000){
- cout<<"1000元大鈔"<<coin/1000<<"張"<<endl;
- coin%=1000;
- }
- if(coin>=500){
- cout<<"500元大鈔"<<coin/500<<"張"<<endl;
- coin%=500;
- if(coin>=100){
- cout<<"100元大鈔"<<coin/100<<"張"<<endl;
- coin%=100;
- }
- if(coin>=50){
- cout<<"50元摳摳"<<coin/50<<"枚"<<endl;
- coin%=50;
- }
- if(coin>=10){
- cout<<"10元摳摳"<<coin/10<<"枚"<<endl;
- coin%=10;
- }
- if(coin>=5){
- cout<<"5元摳摳"<<coin/5<<"枚"<<endl;
- coin%=5;
- }
- if(coin>=1){
- cout<<"1元摳摳"<<coin/1<<"枚"<<endl;
- }
- }
- }
- cout<<endl<<"再次感謝您使用本系統"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |