
Larissa P. answered 02/10/21
Mid-Level Software Engineer
Hi Bob,
The focal point of this question is around the assignment operator `-=`, let's break down the two parts of this operator.
The first part of the operator and the most simple assignment operator is `=`, this simply assigns a value to a given variable i.e. setting the balance variable to 1020.37. This just lets us be able to tell the computer to hold a certain value assigned to a name we choose to let us ask for it later.
The second part of this operator is the subtraction operator `-`. This is the same as what we usually reference as a subtraction sign, i.e. "5 - 3 = 2". In this question, it is exactly that as well. It lets us tell the computer we want to subtract a number.
Combining these together allows a "short hand" way to express an express less different to us.
`balance -= amount` is the same thing (equivalent to) `balance = balance - amount`
Try replacing the line `balance = balance - amount`.
Can you figure out the answer given this information?
Some resources to take a look at: https://www.tutorialspoint.com/java/java_basic_operators.htm, https://morioh.com/p/e5ec3d3cd3ff (some good examples of what the other link describes).