Please write in JAVA In the Print class, implement a static method named printNumbers that will print out numbers in brackets, formatted as [1][2][3], and so on. The method should accept two integer...


Please write in JAVA


 In the Print class, implement a static method named printNumbers that will print out numbers in brackets, formatted as [1][2][3], and so on. The method should accept two integer parameters: howMany and lineLength. The signature of the method should be “public static void printNumbers(int howMany, int lineLength)”. The method should print numbers from 1 to howMany in the previous format, but it should not output more than lineLength characters on any one line. It should not start a [ unless it can fit the corresponding ] in the same line. Some sample inputs and expected output is shown below.



howMany<br>lineLength<br>Output<br>14<br>12<br>[1][2][3][4]<br>4<br>10<br>[1][2][3]<br>[4]<br>[1]<br>[2]<br>[3]<br>3<br>2<br>Error! lineLength must at least be 3.<br>LO<br>3.<br>

Extracted text: howMany lineLength Output 14 12 [1][2][3][4] 4 10 [1][2][3] [4] [1] [2] [3] 3 2 Error! lineLength must at least be 3. LO 3.

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here