Avsnitt 1. Kapitel 38
single
Challenge: for Loop
Svep för att visa menyn
Uppgift
Svep för att börja koda
Imagine you are buying several items in a shop. Each item costs the same amount, and you want to calculate the total cost of all items.
- Initialize
totalCostto0. - The loop should start with
i = 0and run whilei < quantity. - Add
itemPricetototalCostinside the loop. - Return
totalCostat the end of the method.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 38
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal