In: Computer Science
Write a spell checking program (java) which uses a dictionary of words (input by the user as a string) to find misspelled words in a second string, the test string. Your program should prompt the user for the input string and the dictionary string. A valid dictionary string contains an alphabetized list of words.
Functional requirements:
dictionary.java
import java.io.*;
import java.util.*;
public class dictionary
{
public static void main(String args[]) throws Exception
{
String dString;
String uString;
Scanner input=new Scanner(System.in);
System.out.println("Enter distionary string :");
dString = input.nextLine();
System.out.println("Enter input string :");
uString = input.nextLine();
String[] dict = dString.split(" ");//split dictionay
string and save to array fo string
boolean found = false;
//ieterate over dictionary string array
for (String a : dict)
{
//compare and print message
accordingly
if((uString.toLowerCase().compareTo(a.toLowerCase())) == 0)
{
System.out.println("word found!");
found =
true;
break;
}
}
if(found == false)
{
System.out.println("Unknown word
found!");
}
}
}