Create a program BloomGrid.java that creates a 5-by-5 2D array, then asks the user for an x and y coordinate. Then, print out the contents of the 2D array, which should have a 3-by-3 plus shape displayed on the grid with the center of the plus being your coordinate. You do not have to make any changes to the grid orientation. If the user places a point at the edge of the grid, you should be able to place any portion of the plus that's still on the grid and not crash.

import java.util.Scanner;
public class BloomGrid {
static boolean isValid(char[][] grid, int x, int y) {
return x < grid.length && y < grid[x].length;
}
static void set(char[][] grid, int x, int y) {
if(isValid(grid, x-1, y)) grid[x-1][y] = 'X';
if(isValid(grid, x, y-1)) grid[x][y-1] = 'X';
if(isValid(grid, x, y)) grid[x][y] = 'X';
if(isValid(grid, x, y+1)) grid[x][y+1] = 'X';
if(isValid(grid, x+1, y)) grid[x+1][y] = 'X';
}
static void print(char[][] grid) {
for(int i = 0; i < grid.length; ++i) {
for (int j = 0; j < grid[i].length; ++j) {
System.out.print(grid[i][j] + " ");
}
System.out.println();
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
char[][] grid = new char[5][5];
for(int i = 0; i < grid.length; ++i) {
for(int j = 0; j < grid[i].length; ++j) {
grid[i][j] = '.';
}
}
System.out.print("Enter a x-coordinate: ");
int x = in.nextInt();
System.out.print("Enter a y-coordinate: ");
int y = in.nextInt();
set(grid, x, y);
print(grid);
}
}
Create a program BloomGrid.java that creates a 5-by-5 2D array, then asks the user for an...
Create a program BloomGrid.java that creates a 5-by-5 2D array, then asks the user for an x and y coordinate. Then, print out the contents of the 2D array, which should have a 3-by-3 plus shape displayed on the grid with the center of the plus being your coordinate. You do not have to make any changes to the grid orientation. If the user places a point at the edge of the grid, you should be able to place any...
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
LANGUAGE: JAVA
Sorting an array: 2. Write a program that asks the user for 5 numbers and stores them in an array called data. Then call a method that accepts the array as an argument, sorts the array in ascending order and prints out the original AND sorted array (Hint: The method does not return anything in this case, so it should be set to void).
*Using C++* You will create a program that uses a Critter class to move around a Grid, which is also a class. The Critter and the Grid classes will be in separate files. The Critter class will have a data member to count the number of moves made. It will also need data members to hold the current x and y coordinates. It will have a member function that randomly moves it one space in one of 4 directions. You...
Write a Java program in Eclipse. . Write a Java program that: 1. Creates an array of 100 integers. Initialize the array to have all zeros. 2. Puts even numbers starting from 6 (excluding multiples of 12) into the first 50 slots of the array above. So numbers 6,8,10,14,16,18,20,22,26, etc. go into the first 50 positions in the array. Print the array. 3. Puts random numbers between 45 and 55 into the second 50 slots of the array above (second...
with C++ You will create a program that uses a Critter class to move around a Grid, which is also a class. The Critter and the Grid classes will be in separate files. The Critter class will have a data member to count the number of moves made. It will also need data members to hold the current x and y coordinates. It will have a member function that randomly moves it one space in one of 4 directions. You...
Create a program in C, for a store, that asks the user to select one of the options below and you must use function pointers to call the user’s choice of function for options 1 through 7 1. Determine and print total revenue. This is calculated as the sum of retail price * retail quantity for all items. 2. Determine and print total sale cost. This is calculated as the sum of sale price * sale quantity for all items...
(C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...
In C plus plus Objective: Create an array of numbers based upon user input. Program logic: Ask the user for how big to size the array. Create an array based upon that size. Ask for a number, add that number to the array. Repeat adding to the end until all numbers have been entered or until they enter -1 for the number. Print the list.
A = randi(6, 7); %creates a 2D array with 6 rows %with random integers sz = size(A); for i = 1:sz(1) for j = 1:sz (2) if rem(j, 2)==0 A(:, j) = 0; end end end Rewrite this code in vectorized form you may not use any loops or if statements). Your answer should be one line of code: