Question: (java) please now Write a method called randomNumber that takes as parameter an integer n and returns a random integer between 1 and n inclusive

 (java) please now Write a method called randomNumber that takes as

(java) please now

Write a method called randomNumber that takes as parameter an integer n and returns a random integer between 1 and n inclusive that is a multiple of 3 (Hint: keep generating an integer using a loop until a multiple of 3 is found). Write a test program that reads from the user an integer greater than 20 then uses the above method to generate five random integers (must use a loop). The program displays the numbers generated. Sample Run 1: Enter an integer greater than 20:40 The random numbers generated as multiples of 3 are: 15 9 18 6 33 Sample Run 2: Enter an integer greater than 20:15 15 is not valid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!