Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C program please Dictionary file Read in the dictionary words from a file. The name of the dictionary file must be dictionary.txt. Make the

In C program please

Dictionary file

Read in the dictionary words from a file. The name of the dictionary file must be dictionary.txt. Make the following assumptions about the dictionary file:

ape apple ball bill bull foot parrot peeble season zebras zoo
  1. Each line contains the words that begin with particular letter.
  2. The words in each line are separated by tab (\t).
  3. Each word consists only of lowercase letters in the range a-z.
  4. The maximum length of a single line is 99 characters.
  5. The maximum number of words is 1000.
  6. If you cannot open the dictionary file, you should print Failed to open dictionary file dictionary.txt, followed by a newline, and then exit the program.

User main menu

Write a C program that presents the user a menu of actions to choose from, namely:

  1. Print the dictionary.
  2. Search a word in the dictionary.
  3. Group of letters.
  4. Quit.

Make a Selection: _

Print the Dictionary

When the user selects this option the program should print in the screen the dictionary words from the dictionary file. After printing the dictionary file contents, it will go back to the main menu only when the user presses any key from the keyboard.

Search a word in the Dictionary

When the user selects this option the program should ask the user which word he/she wants to search for, open the dictionary file and read the words, and compare each word from the dictionary with the word the user provided. Then it will print to the screen if the word is in the dicitonary or not. After printing the result from the search, it will go back to the main menu only when the user presses any key from the keyboard.

Group of Letters

When the user selects this option the program should prompt the user for a string that contains a series of letters. The program will read in the letters and print out which dictionary words can be made from the provided letters.

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.

The program will print the words that can be made using the provided letters, and , it will go back to the main menu only when the user presses any key from the keyboard.

For instance, the following would be some output from your program ( each example below represents a situation where the user selected the "Group of Letters" option):

------ first example ----

enter letters: alblldi

alblldi:

ball

bill

press any key to go back to the main menu _

------ second example ----

enter letters: moo

moo:

press any key to go back to the main menu _

------ third example ----

enter letters: bleppa

bleppa:

ape

apple

press any key to go back to the main menu _

Group of Letters - Requirements

The program must meet the following requirements for the group of letters option:

  1. The program prints words in the dictionary that could be made in alphabetic order, as specified in the dictionary.
  2. 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).
  3. Each word that could be made is prefixed by a tab character (\t).
  4. If the user types an upper case letter your program must convert it to lower case.
  5. Your program must check if each character is a valid letter of the English alphabet, if it is not then that character is discarded.

Group of Letters - Implementation Hint

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Which is the strongest acid? H2O H3O+

Answered: 1 week ago