Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add 5 to the variable num using an assignment operator.
Java
int num = 10; num [1] 5;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' will subtract instead of add.
Using '*' or '/' will multiply or divide, not add.
✗ Incorrect
The '+=' operator adds the right value to the variable and assigns the result back to it.
2fill in blank
mediumComplete the code to multiply value by 3 using an assignment operator.
Java
int value = 4; value [1] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of multiply.
Using '-=' or '/=' will subtract or divide, not multiply.
✗ Incorrect
The '*=' operator multiplies the variable by the right value and assigns the result back.
3fill in blank
hardFix the error in the code by choosing the correct assignment operator to subtract 2 from count.
Java
int count = 7; count [1] 2;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will increase instead of decrease.
Using '*=' or '/=' will multiply or divide, not subtract.
✗ Incorrect
The '-=' operator subtracts the right value from the variable and assigns the result back.
4fill in blank
hardFill both blanks to divide total by 4 and assign the result back, then add 10 to total.
Java
int total = 40; total [1] 4; total [2] 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up '+' and '-' operators.
Using '*=' instead of '/=' for division.
✗ Incorrect
First, '/=' divides and assigns. Then, '+=' adds and assigns.
5fill in blank
hardFill all three blanks to multiply score by 2, subtract 5, then add 3.
Java
int score = 10; score [1] 2; score [2] 5; score [3] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' instead of '*=' for multiplication.
Mixing the order of operations.
✗ Incorrect
Use '*=' to multiply, '-=' to subtract, and '+=' to add.