prelim1fall2003 - CS100J Prelim I, 29 Sept. 2003 CORNELL...

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

View Full Document Right Arrow Icon
1 NAME (PRINT LEGIBLY!)___________________________________________ (last, first) This 90-minute exam has 6 questions worth a total of 100 points. We suggest that you 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 (20 points). Write the body of method fixCase, which is specified below. Remember that a string can be empty (can contain 0 characters). Also, class String has the following methods: • 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.toLowerCase() = s but with all its letters in lower case • s.toUpperCase() = s but with all its letters in upper case • s.indexOf(c) = index of the first occurrence of character c in s (-1 if none) /** If the first character of s is ‘a’, then return s but with all its letters in lower case. If the first character of s is ‘A’, then return s but with all its letters in upper case. If the first character of s is a blank, then return s but with the first occurrence of new line character ‘\n’ in it removed (if present). Otherwise, return s.
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.

Page1 / 5

prelim1fall2003 - CS100J Prelim I, 29 Sept. 2003 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