- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- cout<<"☆★☆智能玩具店☆★☆"<<endl;
- int buy[7];
- int buycount[7];
- string j[7]=
- {
- "(1)遙控汽車",
- "(2)飛機模型",
- "(3)足球 ",
- "(4)拼圖 ",
- "(5)玩具槍 ",
- "(6)可愛玩偶",
- "(7)籃球 "
- };
- int n[7]=
- {
- 450,
- 550,
- 325,
- 200,
- 660,
- 150,
- 380
- };
-
- for(int i=0;i<7;i++)
- {
- cout<<j[i]<<"\t"<<n[i]<<"元"<<endl;
- }
- int king=0;
- int index=0;
- int num=0;
- int count=0;
- int total=0;
- cout<<"輸入0結帳"<<endl;
- while(true)
- {
- while(true)
- {
- cout<<"請輸入商品代碼"<<endl;
- cin>>num;
- if(num==0)
- {
- break;
- }
- buy[index]=num;
- cout<<"請輸入數量"<<endl;
- cin>>count;
- buycount[index]=count;
- total=total+n[num-1]*count;
- index++;
- }
- cout<<"是否要繼續購買? (1)要 (2)不要"<<endl;
- cin>>king;
- if(king==1)
- {
- continue;
- }
- else
- {
- cout<<"[購物清單]"<<endl;
- cout<<"--------------------------"<<endl;
- for(int i=0;i<index;i++)
- {
- cout<<j[buy[i]-1]<<" "<<n[buy[i]-1]<<"元 => "<<buycount[i]<<"個"<<endl;
- }
- cout<<"--------------------------"<<endl;
- cout<<"總金額:"<<total<<endl;
- break;
- }
- }
- system("pause");
- return 0;
- }
複製代碼 |