16-Section-Handout

16-Section-Handout - CS106X Winter 2008 Handout 16 Section...

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

View Full Document Right Arrow Icon
CS106X Handout 16 Winter 2008 January 23, 2008 Section Handout Problem 1: Using the Scanner and Stack classes <html><b><i>CS106 rules!</i></b></html> Web browsers use stacks to track html tags such as <b> , <i> or <html> . Every html tag must be matched by an equivalent closing tag— <b> , <i> or <html> . Microsoft is looking for programmers to help implement this feature in the next version of Internet Explorer and you, armed with your newly acquired knowledge of classes, decide to volunteer for the job. Using the Scanner and Stack classes to write the following function: bool IsCorrectlyNested(string htmlStr); You can assume that all the tags in the html string will be correctly formed. That is, once you see an angle bracket, it will be followed by the remainder of a complete and well- formed tag (So, nothing like " <<html> "). Problem 2: The Writing Center In an effort to improve your English Literature grade, you’ve decided to write a program that reads in one file (presumably your first draft) and writes the improved version to another. Feedback on prior papers suggests you’d do better to cut out the adjectives and to use stronger verbs. So, you’d like to automate the rewrite process. (Or rather, "you’d proposition to automatize the rewrite process." Wow! That is SO MUCH CLEARER!) Write a function called ImprovePaper , which reads your first draft from the specified and writes the "better" version to the specified , using the supplied thesaurus (which maps words to synonym sets), and removes all adjectives and replaces all verbs with the longest synonym in the corresponding synonym set. Fortunately, someone else gave you code that magically tells you whether a word is being used as a verb or an adjective. These functions have the following prototypes: bool isAdjective(string word); bool isVerb(string word); You should assume that the files have been properly opened and that no error checking (beyond the end-of-file check) need be done. You should assume that the supplied
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 / 4

16-Section-Handout - CS106X Winter 2008 Handout 16 Section...

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