iT邦幫忙

0

求C++問題:製作一個販賣紀錄器,求程式怎麼打?

c++

https://ithelp.ithome.com.tw/upload/images/20210422/20136912PtQgQwfHz6.png!https://ithelp.ithome.com.tw/upload/images/20210422/20136912WqTfHtOmbX.png

看更多先前的討論...收起先前的討論...
圖片 啊???累了!!又那麼糊。
先學會PO上程式碼吧。
懶的放程式,你懶我也懶的看。
dada565 iT邦新手 5 級 ‧ 2021-04-22 22:15:16 檢舉
可是明天要期中考
結構(Struct)或類別(Class)參考看看~
小魚 iT邦大師 1 級 ‧ 2021-04-22 22:26:42 檢舉
我先教你怎麼打錢到我的帳號
淺水員 iT邦大師 6 級 ‧ 2021-04-22 22:28:24 檢舉
建議問同學會比較快,網路問還要打字,效率比不上面對面教學
小魚 iT邦大師 1 級 ‧ 2021-04-22 23:18:27 檢舉
考前一天晚上就不叫問問題了 XD
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
JamesDoge
iT邦高手 1 級 ‧ 2023-01-03 04:31:44

用C++製作一個販賣紀錄器:

#include <iostream>
#include <string>

int main() {
  // 宣告變數
  std::string client;
  std::string fruit;
  std::string phone_number;
  double rate;
  double fee;
  double fruit_price;
  double total_amount;

  // 讓使用者輸入資料
  std::cout << "請輸入顧客名稱:";
  std::cin >> client;
  std::cout << "請輸入購買水果名稱(apple、banana 或 orange):";
  std::cin >> fruit;
  std::cout << "請輸入手機號碼:";
  std::cin >> phone_number;
  std::cout << "請輸入稅金(百分比):";
  std::cin >> rate;
  std::cout << "請輸入手續費:";
  std::cin >> fee;

  // 根據購買的水果種類計算價格
  if (fruit == "apple") {
    fruit_price = 10;
  } else if (fruit == "banana") {
    fruit_price = 20;
  } else if (fruit == "orange") {
    fruit_price = 30;
  }

  // 計算總金額
  total_amount = fee + (fruit_price * rate) + fruit_price;

  // 顯示結果
  std::cout << "顧客名稱:" << client << std::endl;
  std::cout << "手機號碼:" << phone_number << std::endl;
  std::cout << "購買水果:" << fruit << std::endl;
  std::cout << "水果價格:" << fruit_price << "$" << std::endl;
  std::cout << "手續費:" << fee << "$" << std::endl;
  std::cout << "總金額:" << total_amount << "$" << std::endl;

  return 0;
}

我要發表回答

立即登入回答