Monday, February 3, 2014
Section 3.1: Numbers - Compound Assignments
40341: Given an integer variable bridgePlayers, write a statement that increases the value of that variable by 4.
bridgePlayers += 4
40342: Given an integer variable profits, write a statement that increases the value of that variable by a factor of 10.
profits *= 10
40189: Write a statement that increments the value of the int variable total by the value of the int variable amount. That is, add the value of amount to total and assign the result to total.
total += amount
40960: Write a statement using a compound assignment operator to add 5 to val (an integer variable that has already been declared and initialized).
val += 5
40961: Write a statement using a compound assignment operator to subtract 10 from minutes_left (an integer variable that has already been declared and initialized).
minutes_left -= 10
40962: Write a statement using a compound assignment operator to cut the value of pay in half (pay is an integer variable that has already been declared and initialized).
pay \= 2
40963: Write a statement using a compound assignment operator to multiply num_rabbits by 4, changing the value of num_rabbits (num_rabbits has already been declared and initialized).
num_rabbits *= 4
Subscribe to:
Post Comments (Atom)
Java Applets Examples
ReplyDeleteapplets for free