{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

InClassExercise15 - • Remember to import appropriate...

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

View Full Document Right Arrow Icon
CS112: In-class Exercise 15 More on files – a spell checker. 1. Create a new project files-15-spellchecker1 . 2. Copy the file dictionary.txt from the usual locations. We are going to use this file of words as a database to check whether a word is spelled correctly. The assumption is that a word is spelled correctly if and only if it is on this list. 3. Create a new class, called Interaction . Delete everything but the outer wrapper. 4. In this Interaction class, create the following method. There are no instance variables yet for this class. We are just going to write this one method and test it. Use local variables where needed. public boolean spelledCorrectly (String word) throws Exception
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { ? } • Remember to import appropriate classes before the outer wrapper so that we have to ability to read and write files. • Write a boolean method, isSpelledCorrectly(String word) throws Exception that will return true if the String word is one of the words in the file. If the String word is not equal to any of the words in the file, then false is returned. ◊ When reading the file, use the Scanner method hasNextLine() to test if there is a next line to be read in the file. ◊ Create an Interaction object, and invoke the isSpelledCorrectly method with input Strings a zymosan garfield nucular ◊ Try using the new command break in your code....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online