logo Practice-It logo

writeNums

Author: Whitaker Brand

Write a method writeNums that accepts an integer parameter n and prints the first n integers starting with 1 in sequential order, separated by commas. For example, the following calls produce the following output:

Call Output
writeNums(5); 1, 2, 3, 4, 5
writeNums(12); 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

Your method should throw an IllegalArgumentException if passed a value less than 1. Note that the output does not advance to the next line.

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.