Main Page

Previous Next

Exercises

  1. Write a program to display a random choice from a set of six choices for breakfast (you could use any set, for example, scrambled eggs, waffles, fruit, cereal, toast or yogurt).

  2. When testing whether an integer is a prime, it is sufficient to try to divide by integers up to the square root of the number being tested. Rewrite the program example from this chapter to use this approach.

  3. A lottery requires that you select six different numbers from the integers 1 to 49. Write a program to do this for you and generate five sets of entries.

  4. Write a program to generate a random sequence of capital letters that does not include vowels.

Previous Next
JavaScript Editor Java Tutorials Free JavaScript Editor