- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int t, q, total=0;
- string n[5]={"玩具車","熊玩偶","羽毛球","乒乓球","玩具槍"};
- int p[5]={450,300,30,10,600};
- cout<<"☆智能玩具店☆"<<endl<<endl;
- cout<<"商品價目表"<<endl<<endl;
- for(int i=0; i<5; i++)
- {
- cout<<"("<<i+1<<")"<<n[i]<<"\t"<<p[i]<<"元"<<endl;
- }
- cout<<"請輸入8來結帳"<<endl<<endl;
- re:
- cout<<"請輸入商品代碼:";
- cin>>t;
- if(t==8)
- {
- goto checkout;
- }else if(t>0 && t<8)
- {
- cout<<"數量:";
- cin>>q;
- total+=p[t-1]*q;
- goto re;
- }else
- {
- goto re ;
- }
- checkout:
- cout<<endl<<"總共"<<total<<"元!"<<endl<<endl;
- system("pause");
- return 0;
- }
複製代碼 |