- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int BUY[7];
- string name[7]=
- {
- "(1)搖控汽車 ",
- "(2)玩具車 ",
- "(3)遙控直升機",
- "(4)足球 ",
- "(5)籃球 ",
- "(6)棒球 ",
- "(7)玩具熊 "
- };
- int num[7]=
- {
- 500 ,
- 1000,
- 540 ,
- 450 ,
- 660 ,
- 5 ,
- 10
- };
- int index = 0;
- cout<<"玩具店"<<endl;
- cout<<"價目表"<<endl;
- for(int i=0;i<7;i++)
- {
- cout<<name[i]<<num[i]<<endl;
- }
- cout<<endl;
- int productnumber=0;
- int count=0;
- int total=0;
- cout<<"輸入-1離開"<<endl;
- while (true)
- {
- cout<<"請輸入商品代碼"<<endl;
- cin>>productnumber;
- if(productnumber==-1)
- {
- break;
- }
- BUY[index] = productnumber;
- cout<<"請輸入數量"<<endl;
- cin>>count;
- index++;
- }
- total=total+(num[count-1]*count);
- cout<<"[購物清單]"<<endl;
- cout<<"----------------------"<<endl;
- for(int i=0;i<index;i++)
- {
- cout<<name[BUY[i]-1]<<endl;
- }
- cout<<"----------------------"<<endl;
- cout<<"總金額為"<<total;
- system("pause");
- return 0;
- }
複製代碼 |