Exercises

Exercise 5-1.

Create a method that counts from 1-10 using each of the while, do...while, and for statements.

Exercise 5-2.

Create a program that evaluates whether a given input is odd or even; a multiple of 10, or too large (over 100) by using four levels of if statement. Then expand the program to do the same work with a switch statement.

Exercise 5-3.

Create a program that initializes a variable i at 0 and counts up, and initializes a second variable j at 25 and counts down. Use a for loop to increment i and decrement j simultaneously. When i is greater than j, end the loop and print out the message “Crossed over!”

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset