Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE OF C++ PROGRAM THANK YOU VERY MUCH. int main() { ifstream infile; infile.ope

ID: 3744872 • Letter: U

Question

USE OF C++ PROGRAM THANK YOU VERY MUCH.

int main()

{

ifstream infile;

infile.open("dictionary_four_letter_words.txt");

string inp = "s";

while (inp != "1")

{

cout << "Enter a word or 1 to quit: ";

cin >> inp;

if (inp == "1")

{

break;

}

if (checkIfPresent(inp))

{

cout << "The word was spelled correctly" << endl;

}

else

{

cout << "The word was not spelled correctly" << endl;

}

}

}

bool checkIfPresent(string word)

{

ifstream infile;

infile.open("dictionary_four_letter_words.txt");

if (!infile.eof())

{

string line;

while (getline(infile, line))

{

if (line == word)

{

return 0;

}

}

}

infile.close();

}

This is my working but not when I type the character it is always say the spell correctly, even I type the numbers. so can any one willing to help thank you very much

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·ake zoom, and xxyt.

Explanation / Answer

#include<iostream>

#include<fstream>

using namespace std;

bool checkIfPresent(string word);

int main()

{

string inp = "s";

while (inp != "1")

{

cout << "Enter a word or 1 to quit: ";

cin >> inp;

if (inp == "1")

{

break;

}

if (checkIfPresent(inp) == 1)

{

cout << "The word was spelled correctly" << endl;

}

else

{

cout << "The word was not spelled correctly" << endl;

}

}

return 0;

}

bool checkIfPresent(string word)

{

ifstream infile;

infile.open("dictionary_four_letter_words.txt");

string dic_words;

while (infile >> dic_words) // in while read word by word from file

{

if(word == dic_words) //if word are match it returns true otherwise false

return true;

}

infile.close();

return false;

}

/*Try this and Modify your bool checkIfPresent(string word) function

use these words in your .text file test the program

bird , lake , zoom , xxyt

malviya hello , apple , thanx

Thank you !

*/