Board logo

標題: 購物系統 (二) [打印本頁]

作者: 陳品肇    時間: 2018-10-11 21:15     標題: 購物系統 (二)

本帖最後由 陳品肇 於 2018-10-20 17:14 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  7.   cout<<"[商品價目表]"<<endl;
  8.   
  9.   string a[7]={"遙控器車","飛機模型","足球  ",
  10.                "拼圖  ","玩具槍 ","可愛玩偶","籃球  "};
  11.   int price[7]={450,550,325,200,660,
  12.                150,380 };
  13.   int p,q,sum=0;    //p商品代碼   q商品數量
  14.   for(int i=0;i<7;i++)
  15.   {
  16.       cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
  17.   }  
  18.   cout<<"(8)結帳"<<endl<<endl;
  19.   
  20.   re:
  21.   cout<<"請輸入商品代碼: ";
  22.   cin>> p;
  23.   
  24.   if(p>=1 && p<=7)
  25.   {   
  26.      cout<<"數量: ";
  27.      cin>> q;
  28.      if(q>0)  //數量>0
  29.      {      
  30.         sum= sum+ price[p-1]*q;  //計算總金額
  31.         goto re;   
  32.      }else   //數量<0
  33.      {
  34.           cout<<"您輸入的數量有誤!!"<<endl;
  35.           goto re;
  36.      }
  37.   }else if(p==8)
  38.   {
  39.       goto checkout;
  40.   }else
  41.   {
  42.        cout<<"您輸入的代碼有錯!!"<<endl;
  43.        goto re;
  44.   }
  45.   
  46.   checkout:
  47.   cout<<"總金額: "<<sum<<"元"<<endl;
  48.   
  49.   system("pause");
  50.   return 0;

  51. }
複製代碼

作者: 蔡依宸    時間: 2018-10-20 17:21

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string n[7]={"遙控汽車","飛機模型","足球  ","拼圖  ",
  7.                     "玩具槍","可愛玩偶","籃球  "};
  8.     int m[7]={100,200,300,400,500,600,700};
  9.     int p,q,sum=0;   
  10.     cout<<"☆★☆ 智障玩具店 ☆★☆"<<endl<<endl;
  11.     cout<<"[商品價目表]"<<endl;
  12.     for(int i=0; i<=6; i++)
  13.     {
  14.         cout<<"("<<i+1<<")"<<n[i]<<"\t"<<m[i]<<"元"<<endl;     
  15.     }
  16.     cout<<"結帳"<<endl;
  17.     re:
  18.     cout<<"請輸入代號";
  19.     cin>>p;
  20.                     
  21.     if(p>=1 && p<=7)
  22.     {
  23.        cout<<"阿數量哩";
  24.        cin>>q;
  25.        if(q>0)
  26.        {
  27.          sum+=q*m[p-1];
  28.          goto re;
  29.          
  30.        }else
  31.        {
  32.             cout<<"打屁阿";
  33.             goto re;
  34.        }      
  35.     }else if(p==8)
  36.     {
  37.           goto pp;
  38.     }else
  39.     {
  40.          cout<<"白癡"<<endl;
  41.          goto re;
  42.     }
  43.     pp:
  44.          cout<<sum<<"元,把錢吐出來"<<endl;
  45.     system("pause");
  46.     return 0;      
  47. }
複製代碼

作者: 蔡季庭    時間: 2018-10-20 17:25

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  7.   cout<<"[商品價目表]"<<endl;
  8.   
  9.   string a[7]={"遙控器車","飛機模型","足球  ",
  10.                "拼圖  ","玩具槍 ","可愛玩偶","籃球  "};
  11.   int price[7]={450,550,325,200,660,
  12.                150,380 };
  13.   int p,q,sum=0;   
  14.   for(int i=0;i<7;i++)
  15.   {
  16.       cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
  17.   }  
  18.   cout<<"(8)結帳"<<endl<<endl;
  19.   
  20.   re:
  21.   cout<<"請輸入商品代碼: ";
  22.   cin>> p;
  23.   
  24.   if(p>=1 && p<=7)
  25.   {   
  26.      cout<<"數量: ";
  27.      cin>> q;
  28.      if(q>0)  
  29.      {      
  30.         sum= sum+ price[p-1]*q;  
  31.         goto re;   
  32.      }else   
  33.      {
  34.           cout<<"您輸入的數量有誤!!"<<endl;
  35.           goto re;
  36.      }
  37.   }else if(p==8)
  38.   {
  39.       goto checkout;
  40.   }else
  41.   {
  42.        cout<<"您輸入的代碼有錯!!"<<endl;
  43.        goto re;
  44.   }
  45.   
  46.   checkout:
  47.   cout<<"總金額: "<<sum<<"元"<<endl;
  48.   
  49.   system("pause");
  50.   return 0;
  51. }
複製代碼

作者: 陳柏霖    時間: 2018-10-25 17:27

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         string name[7]={"遙控器車","飛機模型","足球    ","拼圖    ","玩具槍","可愛玩偶","籃球    "};
  7.         int dollar[7]={450,550,325,200,660,150,300};
  8.         int x ,z ,s=0;
  9.         cout<<"[商品名稱]"<<endl;
  10.         for(int i=0; i<7; i++)
  11.         {
  12.                 cout<<"("<<i+1<<")"<<name[i]<<"\t"<<dollar[i]<<"元"<<endl;
  13.         }
  14.         cout<<"(8)結帳"<<endl<<endl;
  15.         re:
  16.         cout<<"請輸入商品代碼:";
  17.         cin>>x;
  18.         if(x>=1 && x<=7)
  19.         {
  20.                 cout<<"請輸入商品數量:";
  21.                 cin>>z;
  22.                 s+=dollar[x-1]*z;
  23.                  goto re;
  24.         }else if(x==8)
  25.         {
  26.                cout<<"總共"<<s<<"元!!!"<<endl;
  27.         }else
  28.         {
  29.              cout<<"輸入錯誤!"<<endl;
  30.              goto re;
  31.          }
  32.         system("pause");
  33.         return 0;
  34. }
複製代碼

作者: 譚詩澐    時間: 2018-10-27 10:33

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  7.   cout<<"[商品價目表]"<<endl;
  8.   
  9.   string a[7]={"遙控器車","飛機模型","足球  ",
  10.                "拼圖  ","玩具槍 ","可愛玩偶","籃球  "};
  11.   int price[7]={450,550,325,200,660,
  12.                150,380 };
  13.   int p,q,sum=0;
  14.   for(int i=0;i<7;i++)
  15.   {
  16.       cout<<"("<<i+1<<")"<<a[i]<<"\t"<<price[i]<<"元"<<endl;
  17.   }  
  18.   cout<<"(8)結帳"<<endl<<endl;
  19.   re:
  20.   cout<<"請輸入商品代碼: ";
  21.   cin>>p;
  22.   if (p>=1&&p<=7)
  23.   {
  24.                  cout<<"數量: ";
  25.                  cin>>q;
  26.                  sum+=price[p-1]*q;
  27.   }else if (p==8)
  28.   goto checkout;
  29.   else
  30.   {
  31.       cout<<"輸入錯誤!"<<endl;
  32.       goto re;
  33.   }
  34.   checkout:
  35.   cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;  
  36. system("pause");
  37.   return 0;
  38. }
複製代碼

作者: 戴安利    時間: 2018-10-27 10:44

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int a, b, sum=0;
  7.    string name[7]={"遙控汽車","飛機模型","足球  ","拼圖  ",
  8.                    "玩具槍 ","可愛玩偶","籃球  "};
  9.    int price[7]={450,550,325,200,660,150,380};
  10.    cout<<"★智能玩具店★"<<endl<<endl;
  11.    cout<<"[商品價目表]"<<endl;
  12.    for(int i=0; i<7; i++)
  13.    cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  14.    cout<<"(8)結帳"<<endl<<endl;
  15.    re:
  16.    cout<<"輸入商品代碼:";
  17.    cin>>a;
  18.    if(a>=1 && a<=7)
  19.    {
  20.    cout<<"數量:";
  21.    cin>>b;
  22.    sum+=price[a-1]*b;
  23.    goto re;
  24.    }else if (a==8)
  25.        goto checkout;
  26.     else
  27.    {
  28.        cout<<"輸入錯誤!!!"<<endl;
  29.        goto re;
  30.    }
  31.     checkout:
  32.     cout<<endl<<"總共"<<sum<<"元"<<endl<<endl;
  33.     system("pause");
  34.     return 0;  
  35. }
複製代碼

作者: 戴唯陞    時間: 2018-10-27 10:57

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int a, b, sum=0;
  7.    string name[7]={"遙控汽車","飛機模型","足球  ","拼圖  ",
  8.                    "玩具槍 ","可愛玩偶","籃球  "};
  9.    int price[7]={450,550,325,200,660,150,380};
  10.    cout<<"童叟無欺商品店"<<endl<<endl;
  11.    cout<<"[商品價目表]"<<endl;
  12.    for(int i=0; i<7; i++)
  13.    cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  14.    cout<<"(8)結帳"<<endl<<endl;
  15.    re:
  16.    cout<<"輸入商品代碼:";
  17.    cin>>a;
  18.    if(a>=1 && a<=7)
  19.    {
  20.    cout<<"數量:";
  21.    cin>>b;
  22.    sum+=price[a-1]*b;
  23.    goto re;
  24.    }else if (a==8)
  25.        goto checkout;
  26.     else
  27.    {
  28.        cout<<"輸入錯誤!!!"<<endl;
  29.        goto re;
  30.    }
  31.     checkout:
  32.     cout<<endl<<"總共"<<sum<<"元"<<endl<<endl;
  33.     system("pause");
  34.     return 0;  
  35. }
複製代碼

作者: 戴偉宸    時間: 2018-10-27 10:57

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int p,q,sum=0;
  7.      string name[7]={"遙控汽車","飛機模型","足球  ","拼圖  ","玩具槍 ","可愛玩偶","籃球  "};
  8.      int price[7]={450,550,325,200,660,150,380} ;   
  9.      cout<<"智能玩具店"<<endl;
  10.      cout<<"[商品價目表]"<<endl;
  11.      for(int  i=0;i<7;i++)
  12.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  13.      cout<<"(8)結帳"<<endl;
  14.      re:
  15.      cout<<"請輸入商品代碼 :";
  16.      cin>>p;
  17.      if(p>=1 && p<=7)
  18.      {
  19.          cout<<"數量 :";
  20.          cin>>q;
  21.          sum=sum+price[p-1]*q;
  22.          goto re;
  23.      }   
  24.      else if(p==8)
  25.          goto checkout;
  26.      else
  27.      {
  28.          cout<<"輸入錯誤!"<<endl;
  29.          goto re;   
  30.      }                           
  31.      checkout:
  32.      cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;
  33.      system("pause");
  34.    
  35.    
  36. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2