Assign numCoins the sum of numNickels and numDimes
Check the final answer first, then review the worked steps.
Answer
\(numCoins = numNickels + numDimes;\)
Approach
numCoins = numNickels + numDimes;
Step-by-step solution
- Identify the uninitialized variable: The error states 'numCoins' is not initialized.
- Calculate the sum: Since 'numCoins' should represent the total of nickels and dimes, assign it the sum of the two variables.
- Add the assignment: Insert the line 'numCoins = numNickels + numDimes;' before the print statement.