Problem specification: In this assignment, you will search for a word in square sized grid of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem specification: In this assignment, you will search for a word in square sized grid of letters. You will write a Java program that reads a grid of letters and a specified word from the user, counts how many times the word appeared in the grid in horizontal orientation (from left to right or from right to left), vertical orientation (from top to bottom or from bottom to top) or diagonal orientation (from upper left to lower right, from lower right to upper left, from upper right to lower left or from lower left to upper right) and prints the total count. An example is shown here where the grid size is 7X7 and you can find the word CAT in all possible orientations. Your program should print how many times in total the specified word appeared in the grid in any of these orientations. Input specification: The input starts with an integer N which represents the grid size (NXN). Next, N lines will follow where each line represents a row of letters. Each line will have exactly N letters in them. The last line is the word you have to search in the grid. The number of characters in the last line does not exceed N. You can assume that the value of N will not exceed 10000. Sample input: 4 WORD OODW RDRO Output specification: The output of your program is a single integer that represents the number of times the word is found in the grid. Note: You must not print anything extraneous (such as "Please enter N" or "the result is"). DWOD WORD 3 ABA BAB ABA AB C TGOC FX AVAATAC Sample output: 3 TUTCZ PM GDCEST B OHQAATL DNXCTAK Y CATRC J 12 Problem specification: In this assignment, you will search for a word in square sized grid of letters. You will write a Java program that reads a grid of letters and a specified word from the user, counts how many times the word appeared in the grid in horizontal orientation (from left to right or from right to left), vertical orientation (from top to bottom or from bottom to top) or diagonal orientation (from upper left to lower right, from lower right to upper left, from upper right to lower left or from lower left to upper right) and prints the total count. An example is shown here where the grid size is 7X7 and you can find the word CAT in all possible orientations. Your program should print how many times in total the specified word appeared in the grid in any of these orientations. Input specification: The input starts with an integer N which represents the grid size (NXN). Next, N lines will follow where each line represents a row of letters. Each line will have exactly N letters in them. The last line is the word you have to search in the grid. The number of characters in the last line does not exceed N. You can assume that the value of N will not exceed 10000. Sample input: 4 WORD OODW RDRO Output specification: The output of your program is a single integer that represents the number of times the word is found in the grid. Note: You must not print anything extraneous (such as "Please enter N" or "the result is"). DWOD WORD 3 ABA BAB ABA AB C TGOC FX AVAATAC Sample output: 3 TUTCZ PM GDCEST B OHQAATL DNXCTAK Y CATRC J 12
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class Puzzle public static void mainString args Scanner scan new Scann... View the full answer
Related Book For
Fundamental Managerial Accounting Concepts
ISBN: 978-1259569197
8th edition
Authors: Thomas Edmonds, Christopher Edmonds, Bor Yi Tsay, Philip Olds
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Ticket to Ride is a popular board game that involves connecting cities in a given railroad network. In this assignment you will prototype some potential approaches for creating an AI player for this...
-
In this assignment you will write a program that will simulate a storage area with collections of items. Items can be added, removed, and the user can check the value of an item. This assignment does...
-
Suppose that a client performs an intermixed sequence of push and pop operations on a pushdown stack. The push operations insert the integers 0 through 9 in order onto the stack; the pop operations...
-
The following selected data were taken from the accounting records of Manitoba Manufacturing Company. The company uses direct-labor hours as its cost driver for overhead costs. Junes costs consisted...
-
Leonard Heinz was recently put in charge of the construction division of McMahan Industries. He has reviewed the plant assets and their related accounting records, and believes certain items are...
-
Many organizations maintain separate bank accounts for payroll, thereby segregating all payroll disbursements from general disbursements, such as payments for purchases, inventory, plant assets, and...
-
To help familiarize you with the financial reporting of a real company in order to further your understanding of the chapter material you are learning. This case focuses on the financial statement...
-
Sofia is playing a game with her friend, Kara, where she throws M&M candies toward Kara. Kara then adjusts the height of her mouth up/down in order to catch the M&M in her mouth, but their horizontal...
-
Two investment projects which are mutually exclusive both require a $10,000,000 investment. Projected cash flows are provided in a table below. Given discount rate of 12 percent, calculate the net...
-
If a taxpayer's Earned Income Credit is disallowed due to reckless or intentional disregard of the rules, there is a waiting period after the disallowance. How long is the waiting period? a) Sixty to...
-
True Or False An insurer cannot terminate a contract on the basis of the insured being convicted of driving while intoxicated.
-
Identify the differences between an annulment and a divorce.
-
Sammy plc reported net sales of 300,000, 330,000, and 360,000 in the years, 2023, 2024, and 2025, respectively. If 2023 is the base year, what is the trend percentage for 2025? a. 77%. b. 108%. c....
-
True Or False Some have suggested that uninsured motorists in no-fault states should not be allowed to recover for their damages.
-
Discuss the surface finishing methods with various applications.
-
A fellow engineer has recorded raw stress-strain data (elongation vs. force) for several samples. Your role is to develop a MATLAB program to simplify the analysis of the many samples available and...
-
Federated Shipping, a competing overnight delivery service, informs the customer in Problem 65 that they would ship the 5-pound package for $29.95 and the 20-pound package for $59.20. (A) If...
-
Fullerton Paper Products Corporation produces paper cups using two production departments, printing and forming. Beginning balances and printing department data for 2018 follow: Accounts Beginning...
-
Vogel Company manufactures scanners that sell for $150 each. The company pays $60 per unit for the variable costs of the product and incurs fixed costs of $1,800,000. Vogel expects to sell 60,000...
-
Airdrie Department Store is divided into three major departments: Men's Clothing, Women's Clothing, and Home Furnishings. Each of these three departments is supervised by a manager who reports to the...
-
Consider a stochastic process such that the underlying security \(S\) follows the model: \[d S_{t}=\mu S_{t} d t+\sigma_{t} S_{t} d Z_{t}\] where \(Z\) is a standard Brownian motion. Suppose the...
-
Calculate the solution to the following SDE: \[d X_{t}=\alpha\left(m-X_{t} ight) d t+\sigma d B_{t}\] with \(X_{0}=x\). The process satisfying this equation is called the meanreverting...
-
Let \(B_{t}\) be a standard Brownian motion started at 0 . Use that for any function \(f\) we have: \[\mathbf{E}\left[f\left(B_{t} ight) ight]=\frac{1}{\sqrt{2 \pi t}} \int_{-\infty}^{\infty} f(x)...
Study smarter with the SolutionInn App