Challenge: Fast-Food Order Calculator
Task
Swipe to start coding
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. 
Solution
solution.cpp
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 7.69
Challenge: Fast-Food Order Calculator
Swipe to show menu
Task
Swipe to start coding
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. 
Solution
solution.cpp
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 2
single