Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the given program in java with comments Your job for this program is to use recursion to count the number of blobs in a

write the given program in java with comments
image text in transcribed
image text in transcribed
Your job for this program is to use recursion to count the number of "blobs" in a 2D array. You will be given a text file containing a 2D matrix of O's and *'s. A blob is connected group of *'s. The *'s are connected if they are von Neumann neighbors (top, bottom, left or right). Follow the guidelines below. Use constants for the number of rows and the number of columns. You will be given a 20 x 20 text file, but it is beneficial to store a border of O's around the actual blob world to make the search for blobs on the edges much easier; i.e. make your array 22 x 22 and store the blob world in locations 1..20, 1..20. Prompt the user for a filename to read in a given text file containing O's and *'s. Scan through the 2D matrix. When you find the beginning of a blob, call a recursive function that will replace all of the *'s in the blob with #'s. Print the original blob world and the mutated blob world as shown in the example. Do not print the border of O's around the actual world. Count the number of blobs found and print the total count under the worlds as shown in the example. Important Reminders: Include an appropriate heading with an explanation of the program in your code comments and in your output. Document your code. Comment, comment, comment. Your name and short explanation of the program should appear at the top of your code. Work incrementally. First make sure you can read in the world from a file and print it out to a file without making any changes. Then, and only then, should you try to modify the world. Upload a copy of all code files (.cpp,.h) to D2L by the due date. 56 blobs were found. ##@@@#@#@@@@@#@#@# # @ et tr t # ## @@@#@@@ @@@@@ ##@@#@@ @@#@@ # # ##@@#@##@@@@ @@@@@@@@@@@@@@@@ # eeeeee 8 @#@#@#@@@@@@ ##@@@ # ##@@@ ##@#@@@@ # @e #@##@#@@ 0 @#@@#@#@@@@@@@ ### @ @ @#@@@#@@ ### # 1 1 0 0 # 00 @@@#@# @#@@@ World with mutated blobs. : BB @ @ @ @ @ @ @ @ @ @ @.@.@@@@.@.@.. @ @.@.@@@@@@@@@@... ..@.@..@@@@@@@@@. .@.@.@@@@@@.0.0..@@ @@@@@@@@@@@@@@@@ . .@@@@@@@@@@@@@@.. .@@.@@@.@.@.@@@@@@ ...@. 0..@@@.. @@..@.@ @@@@@... . ..@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@... O....@@ @@.@....@@@@@@@@@ @@..@@...@@@@@@@@@ @@@@@@@...@.@@@@@@ 0.0.0.0 . @ @@@@ eee Original world: of program should be here *** heading and explanation *** Your output Example

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions