セクション 1. 章 8
single
Challenge: 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.
- Initialize a variable
totalto0.0to store the total order price. - Iterate through the
itemsarray using a loop. The array size is equal ton, which is passed as the second parameter to thecalculateTotalOrderfunction. - For each item, check its name using
if / else ifand add the corresponding price tototal."Burger"→ $5.0"Pizza"→ $8.0"Hot dog"→ $4.0
- Apply a 10% discount if the
totalexceeds $20 by multiplyingtotalby0.9. - Return the final
totalfrom the function.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 8
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください