Section9Key 1 - / l. One possibl-e public if Sotutlon...

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: / l. One possibl-e public if Sotutlon solution to CSE143 Section bel-ow. #9 problems appears (int int factorial n) { (n < 0) throw new IllegalArgumentException (n else if 0) return L; el-se return (n n * factorial 1); solution () ; i 2. One possj-ble public if appears below. int. mul_tipJ_yEvens (int n) { (n < 1) throw new IllegalArgumentException (n else if 1) return 2; el-se return 2 * n * multiplyEvens(n sol_ut ion O; .. 1); ) 3 . One pos s ible public if appears b e l _ o w. String (j-nt n) { starString (n < 0) throw new IllegalArgumentException (n el-se if 0) fetUfn rr*tr! () ; else return ) 4. One possible public if solution appears beLow. starString(n 1) + starString(n 1); double sumTo (int n) t (n < 0) throw new IllegalArgumentException (n el-se if 0) return 0.0; el se return sumTo(n 1) + 1.0 / n; solution appears bel-ow. () ; i 5. One possib}e public if void writeNums (int n) { (n < 1) throw new IllegalArgumentException (n el-se if 1) q\ref om nrrt nri i/r nf rrr L /1\ \r / . , () ; else { writeNums Qrrqlam arrf (n 1); / ll \ , tt + n); n . y l rr.ri r u n t - ) ) ...
View Full Document

This note was uploaded on 11/03/2009 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Ask a homework question - tutors are online