
Implement the vacuum cleaning agent function in Python/Java for the scenario described below: Consider two-dimensional Boolean array of size m x n (m and n can each be equal to 4) where m is the number of rows, and n is the number of columns. Obtain numerical positive integer values for m and n as inputs from the user. Generate random numbers and scale them down to either a “0” or a “1” according to whether they represent “Clean” or “Dirty”, respectively. After filling the array with 0s or 1s, start at some random array position indicating the initial position of the vacuum cleaner. First check if at that current position, there is the presence of a “Dirt” or not determined by whether 0 or 1 is filled in at that initial position of the vacuum cleaner. If there is a “Dirt”, clean it, and if there is no “Dirt” do a No-operation. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If it is feasible to move to the left, right, up, or down, then move and repeat the process. If it is not feasible to move to the respective positions, then repeat the generation of random numbers modulo 4 and generate numbers 0, 1, 2, or 3. Take decisions whether to move left, right, up or down now and continue the process of cleaning the respective array positions. You can stop the process when all array positions are cleaned. You need to show the source code and the output. The output needs to be shown after the result of each action. The output can be shown as a 4 x 4 square grid (matrix-like) containing numbers 0s and/or 1s.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

- Use Java to write a program that prompts the user for a positive odd integer , generates a normal magic square of order size of that integer, and prints it with numbers right-justified and aligned in evenly-spaced columns. (Magic square definition: https://en.wikipedia.org/wiki/Magic_square. Can assume that the numbers in the square are 3 digits or less (i.e. size ≤ 31). Have the construction of the 2D integer array magic square take place in a public static method getMagicSquare that takes in an integer n as a parameter and returns the 2D integer array magic square as specified. Your main method should perform input and output (I/O) and call this method to perform the computation. Methods for generating a magic square : Assign 1 to our initial current position: the bottom row, middle column. Place each successive value (up to size * size) in the first of the following positions that is unoccupied: (1) one space down and to the right, or (2) one space up. Positions wrap around…arrow_forwardGiven an array below, write a Java program to take input an integer n from the user and print the "True" or "False" depending upon the number n is present twice in the array or not. int [Jarr = {12,-67,13, 15, 12, 15, -67, 0, 1,1}arrow_forwardThe programming language used is Javaarrow_forward
- Write a Java program that reads an integer N from the user and declares an integer array of size N. It then inputs N non-negative integers from the user into the array and do the following: 1. Finds and prints the minimum, maximum, sum, and average of the numbers. 2. Displays array data as a histogram – graphically by plotting each numeric value as a bar of asterisks (*) as shown in the example diagram. This is somehow similar to Lab11 Sample output 9 Enter the size of array: Enter 9 integer values: 10 19 14 Minimum -o Maximum - 19 = 68 Sum Average = 7.55 ========== Histogram: - ------= Element Ualue Hintogran 19 ***** ***** 11arrow_forwardUse Java language and the last digit of ID is a 7arrow_forwardI need help with creating a Java program described below: Minesweeper.Write a program that reads three numbers, m, n, and p and produces an m-by-n Booleanarray where each element is occupied with probability p. In the minesweeper game, occupiedcells represent bombs and empty cells represent safe cells.Print out the array using an asterisk for bombs and a period for safe cells.Then, create an integer two-dimensional array with the number of neighboring bombs (above,below, left, right, or diagonal). * * . . . * * 1 0 0. . . . . 3 3 2 0 0 . * . . . 1 * 1 0 0Write your code so that you have as few special cases as possible to deal with, by using an(m+2)-by-(n+2) Boolean array.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





