Section9Problems 5 - -2 Write that n as a parameter and...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
-2. Write a method writeSquares that takes an integer n as a parameter and t.hat wrj-tes the first n squares to System.out separated by comrnas with odd squares in descending order followed by the even squares in ascending order. For exampl-e, the call: writeSquares (5) i shoul-d produce f ollowing output: 25 , 9, L, 4, 1,6 The odd squares (25, 9, and 1) appear descending b1 (4 and 16) in ascending Notice corT\mas are used to separate consecutive values j-n Iist. Your method shoul-d send its output to System.out and shoul-d not call println. For example, the following calls: i System.out.printtn O; / / to compJ-ete the line of output (1); System.out.printlnO; // to complete (8); should produce exactly three Iines of output: 25, 9, L, 4, l6 1 49, 9, r, 4, 16, 36, 64 You must exactl-y reproduce format of these examples. Your method shoufd throw an IllegalArgumentException if passed a vaLue less than 1. 13. Wri-te a method writeSequence and writes a symmetric sequence of n numbers with descending
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

Section9Problems 5 - -2 Write that n as a parameter and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online