![]() |
CSE 143 Summer 2001Homework 1Due: Electronic submission by 9:30 pm, Wednesday, June 27. Paper receipt and written report due in quiz section the following day. |
A small start-up named Microsoft is working on a new word processing program, Word. They need help implementing the document spell-checking feature and have hired you for the job. (Sorry, no stock options involved). As with all assignments, please read the instructions all the way through before beginning. Read them once again before you turn in your assignment, to be sure you've left nothing out.
The purpose of this assignment is to review some ideas from previous courses and explore basic parts of C++.
The program should operate in two phases:
The file contains two pieces of information for each word: The misspelled version of the word, and its correct spelling . To keep things simple, words are restricted to be a single string. So, for example:
meloncholy melancholy
would be a correct entry, but,
Seattle Maraner Seattle Mariner
would not.
The end of the file is indicated by an entry with the symbol ". ." (two single period, separated by a space.).
You may assume that there are at most 30 total words in the input file (not including the end marker with periods as the word). You should also assume that the input file contains clean data, i.e., you do not need to check for input errors like duplicate words, poorly formatted words, etc.
Example: Here is a sample words.txt file giving various misspelled words.
mispelled misspelled
Mispelling Misspelling
Maraners Mariners
acentuate accentuate
teh the
certanly certainly
Teh The
cemetary cemetery
wierd weird
exceding exceeding
ar are
. .
Once the program has read the words.txt file, it should prompt the user to enter a sentence, terminated by pressing <enter>. You may assume that sentences are at most 200 characters long. When the user presses <enter> your program should:
The word must exactly match the name in the database, including capitalization.
When the user is done, she should enter a single period (".") to indicate that the program should terminate execution.
Example: Here is a sample of what the interaction should look like, using the data given above. User input is underlined and in italics, like this.
Enter sentence: Teh Maraners ar exceding expectations The Mariners are exceeding expectations. 4 Errors Found Enter sentence: Mispelling words is certanly a problem Misspelling words is certainly a problem 2 Errors found Enter sentence: .
A primary purpose of this assignment, besides learning basic C++, is for you to gain experience designing a program, including data structures, breaking the code apart into functions in some sensible way, and so forth. But there are a few specific implementation requirements - things you must do as specified here.
You should split your code into two different source files, and partition your code into the files so that related code is together. In particular, you will need a data structure to hold the mispelled/correctly spelled word pairs. You will also need various functions to manipulate this data structure, for example, adding new information to it, looking up a word in the structure, getting the correctly spelled version, etc.
You must separate your source code so that the functions that process the internal details of the word data structure are in a separate source (.cpp) file from the main program. You will also need an associated header (.h) file containing declarations of the data structure(s) and function prototypes for the routines in this source file. The source (.cpp) file containing the main program should #include the header file to access the data structure definitions and function prototypes. The main program must call appropriate functions to manipulate the misspelled word data structure - it should not access the internal details itself.
cin
, cout
,
ifstream
, etc.). Do not use
printf/scanf/fscanf
or other C library functions for I/O.
#include "file.h"
to include header files
that you write and that are in your project folder. The angle brackets
in #include <library>
are used to indicate libraries that
are part of Visual C++ or other implementations
Part of your job as a programmer is to verify that your code works by running appropriate tests. That means more than just trying it with the example data given above. You need to invent test data that will check your program under various conditions. For example, your tests should check that the program works properly if
As part of the report you turn in with this assignment (see below), you will need to describe how you tested the program and why you believe that your tests demonstrate that it works properly.
There is no sample program for this assignment; you should create a program that works as specified. In cases where the specification is not clear, you may need to make some reasonable assumptions. Also, feel free to discuss issues about the specifications on the course newsgroup, in sections, with your colleagues, etc.
In any non-trivial project, programming or otherwise, the job can often seem overwhelming at first - too many things to do all at once and no clear idea where to start. An important skill to develop is to figure out what you can do first, without having to finish other things. Here are some suggestions.
Time spent planning and thinking at the beginning of the project will be more than repaid by time saved that would otherwise be needed to debug and fix problems.
When you turn in your program, you must also turn in a short report that discusses the following issues:
This report need not be long, but it should be complete enough to give us a good picture of what you accomplished.
When you've finished your program, turn it in using this turnin form. Print out the receipt that appears, staple it and your report together, and hand it in during quiz section.