返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         string name[]={"ALTIS","RAV4 ","CAMRY","YARIS","AURIS","C-HR ","SUPRA"};
  7.     int price[]={750000,1200000,920000,585000,850000,850000,2030000};
  8.         cout<<"☆★☆TOYOTA商場 ☆★☆"<<endl<<endl;
  9.         cout<<"【商品價目表】"<<endl;
  10.         int p,q,sum=0;
  11.         for(int i=0; i<7; i++)
  12.             cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  13.         cout<<"(8)結帳"<<endl<<endl;
  14.         cout<<"輸入<8>開始結帳"<<endl<<endl;
  15.         re:
  16.         cout<<"請輸入商品代碼: ";
  17.         cin>>p;
  18.       
  19.         if(p>=1 && p<=7)
  20.         {
  21.                 cout<<"請輸入商品數量: ";
  22.                 cin>>q;
  23.                 cout<<endl;
  24.                 if(q>0)
  25.                 {
  26.                         sum=sum+price[p-1]*q;
  27.                         goto re;
  28.                 }else
  29.                 {
  30.                         cout<<"輸入錯誤誤誤...!!"<<endl;
  31.                         cout<<endl;
  32.                         goto re;
  33.                 }
  34.         }else if(p==8)
  35.             {
  36.                     goto checkout;
  37.                 }else
  38.                 {
  39.                         cout<<"輸入錯誤誤誤...!!"<<endl;
  40.                         cout<<endl;
  41.                         goto re;
  42.                 }
  43.                 checkout:
  44.                         cout<<endl;
  45.                     cout<<"總金額是: "<<sum<<"元!"<<endl;
  46.         system("pause");
  47.         return 0;
  48. }
複製代碼

TOP

返回列表