This project is for my Intro to C code Class for my AA degree. Deadline is 3 weeks, due on the 13th of december
Write a C program that prompts the user for a series of letters. The program will read in the letters and print out which dictionary words can be made from the provided letters. The dictionary is provided as a text file.
In very general terms, determining if a given word can be made from the given letters will require counting how many distinct kinds of letters there are in the given letters and in the words.
For example, assume that the word “bull” is in the dictionary. The word “bull” contains 1 ‘b’ character, 2 ‘l’ characters, and 1 ‘u’ character. Now say the input letters were “alblldi”. In “alblldi”, we have enough ‘b’ characters for “bull”, since “alblldi” contains at least 1 ‘b’ character. Similarily, “alblldi”, has enough ‘l’ characters for “bull”, since “alblldi” contains at least 2 ‘l’ characters. However, “alblldi” does not have at least 1 ‘u’ character, and as such we know that we cannot make “bull” from “alblldi”.
Read in the dictionary words from a file. The name of the dictionary file must be “[login to view URL]”. Make the following assumptions about the dictionary file:
Each line contains the words that begin with particular letter.
The words in each line are separated by tab (\t).
Each word consists only of lowercase letters in the range a-z.
The maximum length of a single line is 99 characters.
The maximum number of words is 1000.
If you cannot open the dictionary file, you should print “Failed to open dictionary file ‘[login to view URL]’”, followed by a newline, and then exit the program.
The program must meet the following requirements:
The program keeps asking the user for letters until the letters are exit.
The program prints words in the dictionary that could be made in alphabetic order, as specified in the dictionary.
The program prints out what letters were typed in, followed by a colon (:), followed by a list of the words that could be made (if any).
Each word that could be made is prefixed by a tab character (\t).
If the user types an upper case letter your program must convert it to lower case.
Your program must check if each character is a valid letter of the English alphabet, if it is not then that character is discarded.
For instance, the following would be some output from your program:
enter letters: alblldi
enter letters: moo
enter letters: bleppa
enter letters: exit
There are a lot of different ways to perform this sort of counting, but the shortest way will probably involve an array of 26 integers, one for each letter of the alphabet. The first index in this array refers to the number of ‘a’ characters, the second index the number of ‘b’ characters, and so on.
If the program runs your maximum grade will be 100/100
If the program doesn’t run your maximum grade will be 50/100
In either case the following will be checked during the grading process:
( 5%) Indentation
( 5%) Meaningful comments (at least 1 per function, and 1 per conditional/repetition statement)
(10%) Reading the dictionary file line by line, and closing the file correctly when finished
(15%) function that can count the number of times each character appears in a given word
(15%) function that can determine if a word can be made given the letter counts for the word and the input letters.
(30%) Iterate through the dictionary, executing the above code for each word in the dictionary. Print out the words that can be made, using the format specified before. In other words, if your program runs and does what it is supposed to do.
(20%) Answering correctly four (4) questions about your code during the one on one project interview.
This is what the preset dictionary txt file looks like -
ball bill bull
12 freelancere byder i gennemsnit $127 timen for dette job
Hi, i have worked with dictionary building data structures before. I have some ideas about how to this. Let me know if you are interested. Thanks in advance.