Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. A word can read horizontally (left or right), vertically (up or down), or along a 45 degree diagonal (in any of the four directions) formed by consecutively adjacent cells of the table; it may wrap around the table's boundaries, but it must read in the same direction with no zigzagging. The same cell of the table may be used in different words, but, in a given word, the same cell may be used no more than once. Write a computer program for solving this puzzle.

Trying to write it java first and then pseudo code.

public class WordSearch {

private static ArrayList board = new ArrayList()

private static Scanner scanner

public static void readBoard() {

while (true) {

line = input next line

if (line equals NULL)

exit from loop

Delete all spaces in line, convert to Uppercase and add to board } }

public static void printBoard() {

rows = getRows();

for (row=0 to rows)

print board.get(row); }

public static int getRows() {

return the number of rows }

public static int getCols() {

return the number of columns }

public static void createScanner() {

try {

scanner = new Scanner(new java.io.File("WordSearchInput.txt")); }

catch (Exception e) {

exit from program } }

public static void processWords() {

while (scanner has a next word) {

word = scanner.next();

findWord(word); }

public static void findWord(String word) {

rows = get the number of rows

cols = get the number of columns

for (row=0 to rows)

for (col=0 to cols)

findWord(word,row,col); }

public static void findWord(String word, int row, int col) {

for (drow=-1 to 1)

for (dcol=-1 to 1)

findWord(word,row,col,drow,dcol); }

public static void findWord(String word, int row, int col, int drow, int dcol) {

rows = get the number of rows

cols = get the number of columns

for (offset=0 to word.length) {

targetRow = row + offset*drow;

targetCol = col + offset*dcol;

if ((targetRow is less than 0) OR

(targetRow is greater than equal to rows) OR

(targetCol is less than 0) OR

(targetCol is greater than equal to cols))

return

boardChar = board.get(targetRow).charAt(targetCol);

wordChar = word.charAt(offset);

if (boardChar not equal to wordChar)

// mismatch, so we're done

return }

print (word, row, col, drow, dcol); }

public static void main(String[] args) {

createScanner();

readBoard();

printBoard();

processWords(); } }

}

Java, Programming

  • Category:- Java
  • Reference No.:- M91380403
  • Price:- $40

Guranteed 36 Hours Delivery, In Price:- $40

Have any Question?


Related Questions in Java

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As