- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main(){
- re:
- system("cls");
- int x,y,sum=0;
- string n[]={"遙控汽車","飛機模型","足球 ","拼圖 ","玩具槍 ","可愛玩偶","籃球 "};
- int price[]={450,550,325,200,660,150,380};
- int qty[]={0,0,0,0,0,0,0};
- cout<<"****智能玩具店****"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0;i<7;i++)
- cout<<"("<<i+1<<")"<<n[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"(8)結帳"<<endl<<endl;
- cout<<"[優惠方案] 滿五千享9折優惠"<<endl<<endl;
- re2:
- cout<<"請輸入商品代碼:";
- cin>>x;
- if (x==8)
- goto checkout;
- if(x>=1 && x<=7)
- {
- cout<<"請輸入商品數量:";
- cin>>y;
- sum=sum+price[x-1]*y;
- qty[x-1]+=y;
- goto re2;
- }
- else
- goto re;
- checkout:
- cout<<endl<<"[購物清單]"<<endl;
- cout<<"----------------------------------------------"<<endl;
- for(int i=0;i<=7;i++){
- if(qty[i]!=0)
- cout<<n[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;
- }
- cout<<"----------------------------------------------"<<endl;
- cout<<"總共"<<sum<<"元!"<<endl;
- if(sum>=5000)
- cout<<"由於消費滿五千,享九折優惠"<<endl<<"您只需要付"<<sum*0.9<<"元,現省"<<sum*0.1<<"元"<<endl;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |