Question
C# program eof! For your program you will search a dictionary file for the word provided by the user. First ask the user to input
C# program eof!
For your program you will search a dictionary file for the word provided by the user. First ask the user to input a word. Search the dictionary file for that word and tell the user whether or not the word was found.
You will need to read through the file one word at a time, comparing each to the word entered by the user. If you find a match, set the value of a boolean flag variable to true, and exit the loop early (you can use a break statement to accomplish this.) After the loop, you can use an if/else statement based on the boolean variable to print out where the users word was a real word or not.
This program demonstrates a linear search technique. When you perform a linear search, you start at the beginning of a list and search through the list in order until you reach the desired item or the end of the list.
dictionary.txt is a dictionary file for Windows that you can use. You must either put your dictionary file in your Visual C# project folder, or specify the path to the dictionary file in your program. Your output should look similar to the following figure. Turn in your completed program.
{
string word; // The word entered by the user string result; // The word read from the file int counter = 0; // Counts the number of lines read from the file bool found = false; // If the user's word has been found ifstream inFile; // The input file
inFile.open("dictionary.txt");
Console.WriteLine("Enter a word to search in dictionary: "); cout << endl;
if (!inFile) { Console.WriteLine("Oh that isnt a real word!"); }
while (inFile >> result) { counter++; } Console.WriteLine("That is real word!"); << counter << endl;
system("pause"); return 0;
}
thats what i have from c++ but i need a c# program and i am trying to convert c++ to c# and go from there on this program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started