Write a method called writeSequence that accepts an integer n as a parameter and prints to the
Question:
Write a method called writeSequence that accepts an integer n as a parameter and prints to the console a symmetric sequence of n numbers composed of descending integers that ends in 1, followed by a sequence of ascending integers that begins with 1. The following table indicates the output that should be produced for various values of n:
Notice that when is odd the sequence has a single 1 in the middle, whereas for even values it has two 1s in the middle. Your method should throw an IllegalArgumentException if it is passed a value less than 1.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: