Trying to write it java first and then pseudo code

Assignment Help JAVA Programming
Reference no: EM13810449

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(); } }

}

Reference no: EM13810449

Questions Cloud

Define the kent and kendall visions of intelligence : What are the most important differences between the Kent and Kendall visions of intelligence. Why are these differences so important and worth discussing. Which vision might be most applicable today and why
What is the variance of these returns : Five years ago, you purchased 600 shares of stock. The annual returns have been 7.2 percent, -19.4 percent, 3.8 percent, 14.2 percent, and 27.9 percent, respectively. What is the variance of these returns?
Use a spreadsheet to construct a pareto chart : The following data is collected from customer complaints about service problems at a hotel. Complaint types are coded A-G. Use a Spreadsheet to construct a Pareto chart for this data.
How should a manager motivate his or her staff members : An essay presents a well-argued discussion or response to a question using analysis and critique of relevant literature. It establishes a proposition or thesis and presents a point of view based on evidence. An essay is written in a logically stru..
Trying to write it java first and then pseudo code : 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. Trying to write it java first and then pseudo code
Determine before tax-costs of debt financing of bond : Use the information below to determine before tax-costs of debt financing of bond S:
Level of detail needed for a complete cost estimate : How will you reach the level of detail needed for a complete cost estimate? What items should you include in your cost estimate that are not explicitly present in the project schedule?
Define men and women handle disease differently : men and women handle disease differently
Genesis energy capital plan report : The Genesis Energy operations management team, nearing completion of its agreement with Sensible Essentials, was asked by senior management to present a capital plan for the operating expansion. The capital plan was not to be a wish list but an analy..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write java application to input three integers from user

Write Java application that inputs three integers from user and displays sum, average, product, smallest, and largest of the numbers.

  Write thejava code for a program

Write theJava code for a program that reads the weight of a piece of luggage and print the proper message, depending on the weight, as per the table below.

  Create dict letter frequencies that reads the file

createDictLetterFrequencies that reads the file and also takes a parameter n. This method should return a dictionary of dictionaries. The outer dictionary associates the previous n letters of a word with an inner dictionary, which indicates the frequ..

  Insert in order functionality to your statistics program

You are to add mean, standard deviation, and insert in order functionality to your statistics list program.

  Design an abstract data type in java

Design an abstract data type in Java that represents a musical pitch

  An api for a library that provides for all these operations

Quaternions can be represented with four (4) real numbers (a,b,c,d). They can be added, subtracted, multiplied and divided. You can multiply a quaternion by a scalar (which produces a quaternion as a result)

  Class that stores information about a report

Create a class that stores information about a report containing multiple currency transactions in multiple currencies. This includes the name of the report and each of the transactions that occurred.

  Write down a program which determines the bonus that must

write a program that determines the bonus that should be paid to employees. bonuses are determined based on the years

  Write a java gui application index2 java

Write a Java GUI application Index2.java based on the program in Step 1 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text

  Rock-paper-scissors :- java problem

Design decision marks are based on how you implemented our programs/classes.

  Explain we have to make a project in java

We have to make a project in java . This is a small deskstop application no specifications given so far . The CD store has CD games and music we can rent a cd or we can buy . This is all we need to develop.

  Write a program to find solution tocryparithmetic puzzle

Write a program (Crypta.java) that finds a solution to the cryparithmetic puzzle: TOO + TOO + TOO+ TOO = GOOD

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd