Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey, im really struggling on this project and was hoping someone could give me some help, thanks Write a Java program name FindWords.java to find

Hey, im really struggling on this project and was hoping someone could give me some help, thanks

Write a Java program name FindWords.java to find words in a matrix. The letters in the matrix look random, but there are several hidden words in the matrix. You program will use a dictionary (provided) to find all the hidden words, and print them out. For example, you will find a file 0606matrix on Canvas, it reads: Here, the first number 6 is the number of rows, the second number 6 is the number of columns. The program name is FindWords.java. We type the following command %java FindWords < 0606matrix The result will be: the he hew ox box ox so The first word the is indicated in the following graph. The word he is indicated in the following graph. 2 The word hew is labeled in the following graph. Similarly, you can locate the other words in the matrix. Please note that when you are trying to find the words in the matrix, you only consider the situation where letters are on the SAME row. The letters of the same word must be adjacent to each other, from left to right. In this project, we do not consider the situation that letters lying out vertically or diagonally. For example, the following combination is not considered in this project. How to determine a sequence of letters is a word? The provide skeleton code reads strings (each is a word) from file words and saves these strings to an array called wordlist. To determine whether a sequence of letters is a word or not, the program compares the sequence of letters (it is a string) against the elements of array wordlist. If there is a match, then this sequence of letters is a word. Can one letter be counted as a word? NO. In our project, we assume each word has at least two letters. How can I compare two strings are equal or not? Use the equals() method in String object. For example, if you have two strings x and y. If they have the same values, x.equals(y) will return Boolean value true. If not, it returns false. How can I read the matrix in my program? You can use Scanner class, such as 3 Scanner scan = new Scanner(System.in); Once the Scanner object is generated, you can use scan.nextInt() to read an integer. You can also use scan.next() to read a token (imagine it is a letter in this project, but Java treats each token as a String instead of a char). Once you get the token (pointed by a String variable, such as myIn), then you can use myIn.charAt(0) to get the first letter as a char. The letters in the matrix can be saved to a 2D array, which can be char data type or String data type. It is your choice.

Array 0606: the file wont upload because its off a school website but here is the array typed out

66

t h e w d q

c g u x o x

s t b o x n

x z a v t w

k v i k z c

n s o c q h

It has to be in a specific method design, I recieved previous assistance that helped me develop the scanner for the array, but i was unsure what a hash set was. Here is the required method format

import java.util.Scanner;

import java.io.*; public class FindWords{

// search word in the array list // return true if found, otherwise false // please finish this method

public static boolean checkword(String[] list, String word){

return false; }

public static void main(String[] args){ // read words from file "words" // the words are saved to array wordlist // Please do not change this part String[] wordlist= new String[99171]; int index=0; try{

Scanner in = new Scanner(new FileReader("words")); while(in.hasNextLine()){ wordlist[index]=in.nextLine(); index++; } }catch(IOException e){ e.printStackTrace(); } // fill the following part // read the matrix // save the letters of the matrix to a 2D array // fill the following part // checks the sequences of letters // to see whether they are words or not } }

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago