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

Write a ReadCorrectWords function... someone asked this before but the answer wa

ID: 3727474 • Letter: W

Question

Write a ReadCorrectWords function...

someone asked this before but the answer was completely wrong

Question 1 Write a ReadCorrectWords function to store all known, correct words for your spellchecker It should have the following parameters in the order provided e . e e a string filename an array of strings correctWords[] the size of the array an integer startlndex Your function should return the total number of correct words in the array correctWords Your function should open the file identified by filename and read lines from the file line by line. The file will have the following format: correctWords.txt chicken fish COW bubbles pear kiwi You can expect exactly one word on each line. Each word is a correct spelling and should be added to the correctWords array. The parameter startindex is the index at which you should begin adding your words in the array If I called your function with the file above and startlndex- 0, your correctWords array should look like this: ["chicken", "fish", "cow" "bubbles", "pear "kiwi"] Your function should return 6 (for 6 words total in the array)

Explanation / Answer

public static int ReadCorrectWords(String fileName, String arr[], int startIndex) { try { Scanner fin = new Scanner(new File(fileName)); if(startIndex < 0 || startIndex >= arr.length) { return -1; } int ind = startIndex; int count = 0; while (fin.hasNext() && ind
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote