- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string name[]={"ALTIS","RAV4 ","CAMRY","YARIS","AURIS","C-HR ","SUPRA"};
- int price[]={750000,1200000,920000,585000,850000,850000,2030000};
- cout<<"☆★☆TOYOTA商場 ☆★☆"<<endl<<endl;
- cout<<"【商品價目表】"<<endl;
- int p,q,sum=0;
- for(int i=0; i<7; i++)
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"(8)結帳"<<endl<<endl;
- cout<<"輸入<8>開始結帳"<<endl<<endl;
- re:
- cout<<"請輸入商品代碼: ";
- cin>>p;
-
- if(p>=1 && p<=7)
- {
- cout<<"請輸入商品數量: ";
- cin>>q;
- cout<<endl;
- if(q>0)
- {
- sum=sum+price[p-1]*q;
- goto re;
- }else
- {
- cout<<"輸入錯誤誤誤...!!"<<endl;
- cout<<endl;
- goto re;
- }
- }else if(p==8)
- {
- goto checkout;
- }else
- {
- cout<<"輸入錯誤誤誤...!!"<<endl;
- cout<<endl;
- goto re;
- }
- checkout:
- cout<<endl;
- cout<<"總金額是: "<<sum<<"元!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |