{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Section9Key 1

# Section9Key 1 - l One possibl-e public if Sotutlon solution...

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

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

{[ snackBarMessage ]}

Ask a homework question - tutors are online