logo Practice-It logo

BJP3 Exercise 5.4: randomX

Language/Type: Java method basics Random while loops
Author: Leslie Ferguson (on 2013/04/01)

(This problem is a modified version of Chapter 5's randomX exercise from the textbook.)

Write a method named randomX that keeps printing lines, where each line contains a random number of x characters between 5 and 19 inclusive, until it prints a line with 16 or more characters. For example, the output from your method might be the following. Notice that the last line has 17 x characters.

xxxxxxx
xxxxxxxxxxxxx
xxxxxx  
xxxxxxxxxxx
xxxxxxxxxxxxxxxxx
Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.