返回列表 發帖

[10/7 作業2 ]購物系統 (二)

本帖最後由 李泳霖 於 2023-10-21 14:15 編輯

新增 "請輸入商品代碼:" 與 "數量:" 的選項,
並於結帳時計算出總共多少錢,執行畫面如下圖所示。



  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     string s[7]={"遙控汽車","飛機模型","足球    ","拼圖  ","玩具槍","可愛玩具","籃球  "  } ;
  8.     int p[7]={450,550,325,200,660,150,380};
  9.     int w,q,m=0;
  10.     cout<<"玩具大清倉"<<endl<<endl;
  11.     for(int i=0; i<7; i++)
  12.     {
  13.             cout<<"("<<i+1<<")"<<s[i]<<"\t"<<p[i]<<"元"<<endl;
  14.     }
  15.     cout<<"(8)結帳"<<endl;
  16.     re:
  17.     cout<<"請輸入商品代碼:";
  18.     cin>>w;
  19.     cout<<"數量";
  20.     cin>>q;
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊
istak.teach2@gmail.com

此帖僅作者可見
istak.teach2@gmail.com

TOP

返回列表