- In in the following function, what is the final value
of i printed in the last statement?
void firstQuestion() {
int i=1;
while (i<20) i+=9; //Same as i=i+9
System.out.println("i=" + i);
}
- How many times was the while loop in question #1 executed?
- Write a loop that prints out all of the even
integers from 2 to 2,000,000.
- Write the code needed to make the empty function below behave as
follows:
- return 0 if
its argument is less than 50.
- return its argument unchanged if it is
in the range from 50 to 59.
- return 0 if its argument greater than 59.
int fiftyFilter( int arg ) {
//Fill in the code that belongs here.
}
- Write the code needed to make the empty function below print out
whether its integer argument,
cents
, is the value of a
penny, nickel, dime, or quarter. If the number of cents passed in as
an argument doesn't represent the value of one of these coins, your
function should print, "I don't recognize that coin."
void nameCoin( int cents ) {
//Fill in the code that belongs here.
}