2.13 Pbo
2.13 Pbo
b. Have the child wave. Assign the value of the wave to “I’m happy”.
c. Have the child say “I would like to exercise today.”
d. Have the child do several exercises (side stretches, touch toes, jumping jacks).
After exercising, have the child stand and say, “I'm all done exercising.”
e. Change the code so that before the child exercises, you declare a variable of
type Integer called numSets. Set the default value to 3. Save your animation.
f. Use this value to control how many sets of exercises the child does.
g. Have the child wave and say goodbye at the end of the animation.
else
7. This example demonstrates the NOT operator. Review the code, then fill in the
blanks below with either “true” or “false”.
class BoolNotDemo {
public static void main(String[] args){
int x = 2;
int y = 1;
boolean bl;
bl = !(x > y); // bl is false
System.out.println("x is not greater than y:"+bl);
bl = !(y > x); // bl is true
System.out.println("y is not greater than x:"+bl);
}
}
8. This example demonstrates assignment syntax. Review the code, then fill in the
blanks below with the results.
class AssignmentDemo2{
public static void main(String[] args) {
int x=5;
int y=10;
x += y;
System.out.println("The += result is:"+ x);
x -= y;
System.out.println("The -= result is:"+ x);
x *= y;
System.out.println("The *= result is:"+ x);
x /= y;
System.out.println("The /= result is"+ x);
}
}