prelim1fall2007 - CS100J Prelim I, 25 Sept. 2007 CORNELL...

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

View Full Document Right Arrow Icon
NAME (PRINT LEGIBLY!)___________________________________________ (last, first) This 90-minute exam has 6 questions worth a total of 100 points. Spend a few minutes looking at all questions before beginning so that you can see what is expected. Budget your time wisely. Use the back of the pages, if you need more space. Question 0 (2 points). Write your netid and your name, legibly, at the top of each page. Question 1 (15 points). Write the body of method fixZip , specified below. The following methods of class String may be useful: • s.length() = the number of characters in s. • s.charAt(k) = the character at position (or index) k of string s • s.substring(h, k) = a string consisting of characters s[h], s[h+1], …, s[k–1] • s.substring(h) = a string consisting of characters s[h], s[h+1], …, s[s.length()–1] • s.indexOf(c) = index of first occurrence of character c in s (-1 if none) • s.indexOf(s1) = index of first char of the first occurrence of String s1 in s (-1 if none) /** s, an address, may be a Cornell address with the wrong zip number. If s contains the substring "Cornell" and also the substring "14850", then return s but with "14850" replaced by "14853". Otherwise, return s. E.g. for s = "Gries; Olin 167; Cornell; Ithaca, NY 14850; USA", return "Gries; Olin 167; Cornell; Ithaca, NY 14853; USA". */ public String fixZip(String s) { } CS100J Prelim I, 25 Sept. 2007 CORNELL NETID ______________________
Background image of page 1

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

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

This note was uploaded on 09/24/2008 for the course CS 101 taught by Professor Gries during the Fall '08 term at Cornell University (Engineering School).

Page1 / 5

prelim1fall2007 - CS100J Prelim I, 25 Sept. 2007 CORNELL...

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