Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please code it in Java !!! Write a program that has a method called findLetter. The method findLetter takes in a 2D array and a

image text in transcribedimage text in transcribed

Please code it in Java !!!

Write a program that has a method called findLetter. The method findLetter takes in a 2D array and a single character. The method will look at the 2D array row by column (check all of row one, followed by row two etc.) to and see at each location if it contains the character. It prints all locations that contain the character. If the character is not in the 2D array it will print -1-1. This program will also have a method called printArray that will print all the characters in the array (you can adapt the method from the previous problems to print a 2D array of characters). You can assume all characters are lower case. You will test your method in the main method of your program by using a Scanner object: Read in two integers (R and C) that represents the rows and columns of a 2D array AND read in character to find in the 2D array ** Then read in (R*C) characters and copy the values into the 2D array. Print the 2D array calling printArray. Then call the method findLetter to print out all the locations of a given character or -1,-1 (to indicate it is not in the 2D array). **Note: the Scanner class does not have a method to read in a single character. Instead you will need to use the method next() to and read the character as a single String. Then you can get the char by applying the String method charAt(0) to the read in String. Sample Input (read 2 ints: row and col and a single char; then read in a sequence of characters to be stored in the 2D array) Sample Output ser 4 3 a servabtya awn vab tya a wn 1,1 2,2 3,0 54t abcdefghijklmnopqrsu abcd efgh ijk! mnop qrsu (-1,-1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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