Calculating Saved Money

With for loop we iterate through every Lily's birthday. When the leading variable is even number, that means Lily has received money and we add this money to her total savings. At the same time we subtract 1 lev - the money , that her brother takes. Then we increase the value of the variable moneyForBirthday, ie. we increase by 10 the sum, which she will receive on her next birthday. Iversely, when the leading variable is odd number, we increase the count of toys. We do the parity check by division with remainder (%) by 2 - when the remainder is 0, the figure is even, and the remainder 1 is odd.

We also add the money from the sold toys to the Lily's savings.

results matching ""

    No results matching ""