Subject Computer Science Java Programming

Question

Data Structures
In this assignment, you will write a spell-checker for text files. Your program should take a file name as a command-line argument and check the file for any misspelled words. If a word is misspelled, the program should output a line number and line containing the word and highlight the word by printing a sequence of carets (‘^’) underneath it on the next line.
Your program should consider any sequence of one or more letters separated by whitespace or punctuation a word. Do not attempt to handle words with apostrophes or other intra-word accents correctly: e.g. “you’re” should scan as “you” and “re”. The Character class has a method isLetter which you can use to determine whether a char is a letter in the alphabet.
The file words.txt contains a list of valid words. Use this file as your dictionary. For each word in the input file, scan through words.txt until a matching word is found; if no matching word is found, consider the word misspelled.
See below for words.txt

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;


public class SpellChecker {
public static void main(String[] args)
{
if(args.length != 1)
{
System.out.println("Please enter in the filename of document to check");
System.exit(0);
}

try{
BufferedReader in = new BufferedReader(new FileReader(args[0]));
int read, lineCount = 0;
String line = "", word = "";
while((line = in.readLine()) != null)...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Problems With Stack
Homework Solution
$40.00
Java
Programming
Coding
Computer Science
Stack
Generic Types
Push
Pop
Peek
Size
Linked List
Functions
Strings
Integers
Summation
Negative Values
Input
Output
Roman Numerals in Java
Homework Solution
$35.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Roman Numerals
Integers
Messages
Input
Output
Arabic Format
Strings
Integers
Railroads Problem
Homework Solution
$100.00
Java Programming
Computer Science
Graph
Input
Arrival
Output
Railroad
Scenario
Location
Bellman-Ford Algorithm in Java
Homework Solution
$40.00
Programming
Computer Science
Java
Bellman-Ford Algorithm
Matrix
Cost
Distance
Iterations
Loops
Conditions
Vertices
Edges
Paths
ArrayList Fraction Objects in Java
Homework Solution
$15.00
Java
Programming
Computer Science
Coding
Arrays
Fractions
Numerator
Denominator
Decimal Values
Sorted List
Algorithms
Loops
Variables
Statements
Conditions
Get help from a qualified tutor
Live Chats