assign2

assign2 - Name: Thomas Keating 1) Inputs: word (string)...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 Name: Thomas Keating 1) Inputs: word (string) Outputs: pluralized word Errors: empty string Pseudocode: word <-- input string length <-- length of word hyphenIndex <-- index of "-" in word lastLetter <-- substring word from (length of word - 1) to length of word lastTwo <-- substring word from (length of word - 2) to length of word minusLastTwo <-- substring word from 0 to (length of word - 2) if length of word = 0 print "error" halt if hyphenIndex = -1 if lastTwo = "us" and word has index > 3 new = "i" word = minusLastTwo + new print word else if lastTwo = "ch", or lastLetter = "s" or "x" new = "es" word = word + new print word p else new = "s" word = word + new print word else leftOfHyphen <-- substring of word from 0 to HyphenIndex word = leftOfHyphen hyphenAndMore <-- substring of word from HyphenIndex to length if length of word = 0 halt if lastTwo "us" and word has index > 3 new = "i" word = minusLastTwo + new + hyphenAndMore print word else if lastTwo = "ch", or lastLetter = "s" or "x" new = "es"
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 word = word + new + hyphenAndMore print word
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/03/2008 for the course CS 111 taught by Professor Hari during the Spring '08 term at Rutgers.

Page1 / 5

assign2 - Name: Thomas Keating 1) Inputs: word (string)...

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

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