Program 5. Spell CheckerWrite a program that employs the four letter word dictionary to check the spelling of an input word (test word)You will need to save the dictionary file (Located on the Data Canvas Page) to a folder on your computer. Forthis program you will prompt the user to enter a four letter word (or four characters). Then using a loop readeach word from the dictionary and compare it to the input test word. If there is a match then you havespellchecked the word. Write a message to the screen indicating that the word was spelled correctly. If you donot find the word in the dictionary (no match) then write a message to the screen indicating that the test wordis not spelled correctly. Show output for the following test words: bird, lake, zoom, and xxyt.NOTE: You may use a loop to repeatedly test a series of words if you like instead of running the program fourseparate times. If you do this you will need to reset the dictionary file after each word.

Question
Asked Sep 8, 2019
85 views

In C++.

Data canvas is a file with bunch of random words. 

 

 

 

Data canvas:

aahs aals abas abba abbe abed abet able ably abos abri abut abye abys
aced aces ache achy acid acme acne acre acta acts acyl adds adit ados
adze aeon aero aery afar agar agas aged agee ager ages agha agin agio
agly agma agog agon ague ahed ahem ahis ahoy aide aids ails aims ains
airn airs airt airy aits ajar ajee akee akin alae alan alar alas alba
albs alec alee alef ales alfa alga alif alit alky alls ally alma alme
alms aloe alow alps also alto alts alum amah amas ambo amen amia amid
amie amin amir amis ammo amok amps amus amyl anal anas ands anes anew anga anil anis ankh anna anoa anon ansa anta ante anti ants anus aped aper apes apex apod apos apps apse aqua arak arbs arch arco arcs area
ares arfs aria arid aril arks arms army arse arts arty arum arvo aryl
asci asea ashy asks asps atap ates atma atom atop auks auld aunt aura
auto aver aves avid avos avow away awed awee awes awls awns awny awol
awry axal axed axel axes axil axis axle axon ayah ayes ayin azan azon
baal baas baba babe babu baby bach back bade bads baff bags baht bail

 

 

 

 

Program 5. Spell Checker
Write a program that employs the four letter word dictionary to check the spelling of an input word (test word)
You will need to save the dictionary file (Located on the Data Canvas Page) to a folder on your computer. For
this program you will prompt the user to enter a four letter word (or four characters). Then using a loop read
each word from the dictionary and compare it to the input test word. If there is a match then you have
spellchecked the word. Write a message to the screen indicating that the word was spelled correctly. If you do
not find the word in the dictionary (no match) then write a message to the screen indicating that the test word
is not spelled correctly. Show output for the following test words: bird, lake, zoom, and xxyt.
NOTE: You may use a loop to repeatedly test a series of words if you like instead of running the program four
separate times. If you do this you will need to reset the dictionary file after each word.
help_outline

Image Transcriptionclose

Program 5. Spell Checker Write a program that employs the four letter word dictionary to check the spelling of an input word (test word) You will need to save the dictionary file (Located on the Data Canvas Page) to a folder on your computer. For this program you will prompt the user to enter a four letter word (or four characters). Then using a loop read each word from the dictionary and compare it to the input test word. If there is a match then you have spellchecked the word. Write a message to the screen indicating that the word was spelled correctly. If you do not find the word in the dictionary (no match) then write a message to the screen indicating that the test word is not spelled correctly. Show output for the following test words: bird, lake, zoom, and xxyt. NOTE: You may use a loop to repeatedly test a series of words if you like instead of running the program four separate times. If you do this you will need to reset the dictionary file after each word.

fullscreen
check_circle

Expert Answer

Step 1

Program Instructions:

  • Use the open() function of fstream to open the file.
  • Use do-while and while loop to repeatedly ask the word from the user and to read data from the file.
  • Use file.clear() and file.seekg(0, ios::beg) to point the file pointer at the beginning of the file.
Step 2

Program:

#include <iostream>

#include<fstream>

#include <cstring>

using namespace std;

int main()

{

     // declaring file

     fstream file;

     string word,user_word, filename;

     // file name

     filename = "data_canvas.txt";

     int found;

     // open file

     file.open(filename.c_str());

     // to repeatly ask the word from user

     do{

          found = 0;

          cout<<"Enter a four letter word (type exit to exit the program):";

          getline(cin,user_word);

          // exit condition

          if(user_word.compare("exit")==0){

               return 0;

          }

          // read every word from file

          while (file >> word)

          {

             ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: The nor of two languages is nor (L1, L2) = {w : w ∉ L1 and w ∉ L2}. Show that the family of regular ...

A: Click to see the answer

question_answer

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Since the full table structure is not given we make suitable assumptions to write the query:For ques...

question_answer

Q: Write a program called StudentTable that prints the below table. Use only print() orprintf(). DO NOT...

A: The program in Java would be using print and printf statements with formatting for left alignment of...

question_answer

Q: I am trying to get the range of bits from a number. For example , if I call bitRange(0x00001234, 0 ,...

A: Step 1: To extract the bits from the hexadecimal number we need to use the shift operator and use bi...

question_answer

Q: What is a program

A: A program is a set of instructions that a computer performs. A program contains a sequence of instru...

question_answer

Q: Write a java program called Sales considering the following directions and the sample run. Practice ...

A: The program has the following steps:Declare the variablesReceive the input from the userCalculate th...

question_answer

Q: create a python program that will ask users to input four different manufacturers of cars(e.g Ford, ...

A: Create a class Car and define _init_ () function which will initialize the value of variables manufa...

question_answer

Q: I could use help with the following SQL questions (the fields ProductModelName, ProductCategory, Pro...

A: As the table name is not shown in the picture, we are assuming the table name as Product. There are ...

question_answer

Q: How can I use a logic gate to test if two numbers are equal?

A: The “Exclusive-NOR” gate is a combination of the Exclusive-OR gate and the NOT gate.