printNumbers
Category: Programming
Author: Stuart Reges
Book Chapter: 5.3
Problem: printNumbers
Write a method called printNumbers that takes a Random object as a parameter and that prints a list of randomly generated numbers ranging from 1 to 50 inclusive (each number being equally likely). The list should be surrounded by square brackets and the numbers should be separated by commas. The method should randomly generate numbers until it generates one that ends in 5. A typical call would look like this: Random r = new Random(); printNumbers(r); The method might fairly quickly generate a number ending in 5: [43, 34, 27, 2, 2, 25] Or it might take a while to get to a number ending in 5: [23, 8, 13, 1, 37, 37, 9, 34, 23, 34, 4, 9, 16, 44, 49, 43, 49, 3, 45] It is also possible that it will immediately generate a number ending in 5: [35] You must exactly reproduce the format of these examples.