Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Fast-Food Order Calculator | Section
/
C++ Conditional Statements
セクション 1.  8
single

single

bookChallenge: Fast-Food Order Calculator

メニューを表示するにはスワイプしてください

タスク

スワイプしてコーディングを開始

You are building a fast-food ordering system. Customers can select multiple items from the menu, and you want to calculate the total price of their order. Additionally, if the total exceeds a certain amount, a discount is applied.

  1. Initialize a variable total to 0.0 to store the total order price.
  2. Iterate through the items array using a loop. The array size is equal to n, which is passed as the second parameter to the calculateTotalOrder function.
  3. For each item, check its name using if / else if and add the corresponding price to total.
    • "Burger" → $5.0
    • "Pizza" → $8.0
    • "Hot dog" → $4.0
  4. Apply a 10% discount if the total exceeds $20 by multiplying total by 0.9.
  5. Return the final total from the function.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  8
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt