2017-10-05 220 views
0

我正在試圖製作一個程序,要求客戶輸入他們想要購買的物品的數量。然後程序會找到小計和總稅金。我對如何添加一個while循環感到困惑,以至於它會一直詢問項目的價格,具體取決於用戶放置了多少項目,然後將所有項目一起添加。Python - While循環

回答

0

您必須添加您嘗試過的以及您卡住的位置。這是一個開始的僞代碼。

read the number of items as num 
initialise total to zero 
while num > 0: 
    read the price of the each item as price 
    calculate the tax and add it to price 
    add the taxed price of each item to total 
    decrement num 
print sum