Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with C Programming assignment
#3
Luckily, the text here already says what your program should do. All of the pre-writing is done, you just have to code it! Sounds like fun to me - pre-writing is a pain in the ass.

Code:
What your program should do

Your program should first read in the dictionary into a two-dimensional character array (from dictionary.txt) and print a message to the screen stating that the dictionary has been loaded.

Then your program should prompt the user to enter a word, all lowercase.

If the word is in the dictionary, you should simply print out a message stating this.

If the word is NOT in the dictionary, then you should provide a list of possible suggestions (of correctly spelled words that the user might have been trying to spell) in alphabetical order.

Here are the criteria for whether or not a real word should end up on this list:

1)    If either string is a substring of the other, and the lengths of the two strings are within 2 of one another.
2)    If either string is a subsequence of the other and the lengths of the two strings are within 2 of one another. (This would get rid of the “car”, “camera” case, for example.)
3)    If the strings are permutations of one the other. (Only try this test if the two strings are of the same length.)
4)    If the matchscore between the two strings is less than 3. (Only try this test if the two strings are of the same length.)

Continue prompting the user to enter words until they decide that they don’t want to enter any more. (Thus, they will be forced to enter the first word, but after that, you’ll provide them a choice as to whether or not they want to enter another word to check.

This bit of text right here is telling you exactly what your main function should look like. Let's have a look

Code:
//PSEUDOCODE
int main(void)
{
  //Your program should first read in the dictionary into a two-dimensional character
  //array (from dictionary.txt) and
  //print a message to the screen stating that the dictionary has been loaded.

  TwoDCharArray = LoadFile("Dictionary.txt");
  print "File Loaded"

  //Then the user should be prompted for the word. Afterwards...
  //"(Thus, they will be forced to enter the first word, but after that,
  //you’ll provide them a choice as to whether or not they want to enter
  //another word to check."
  //This sounds like a do-while statement!
  do
  {
    //"Then your program should prompt the user to enter a word, all lowercase."
    print "Please enter a word all in lowercase"
    UserInput = GetUserInput()

    //"If the word is in the dictionary, you should simply print out a message stating this."
    if(IfInDict(UserInput))
    {
      print "Great, %s is in the dictionary!", UserInput
    }
    //"If the word is NOT in the dictionary, then you should
    //provide a list of possible suggestions in alphabetical order.
    else
    {
      print "Here are a list of words you could have meant"
      RunThroughDictionary(UserInput) //Gets all of the new words and prints them
    }
  //Continue prompting the user to enter words until they decide
  //that they don’t want to enter any more
  UserInput = GetUserInput("Would you like to do another word?")
  }while(UserInput == 'y' || UserInput == 'Y');

  return 0;
}
Reply


Messages In This Thread
Need help with C Programming assignment - by Fiel - 2009-11-23, 09:18 PM
Need help with C Programming assignment - by Fiel - 2009-11-23, 09:22 PM
Need help with C Programming assignment - by Fiel - 2009-11-25, 08:13 AM
Need help with C Programming assignment - by Fiel - 2009-11-25, 11:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)