Question
I need help with this program please 1. Please copy the following code into your IDE and ensure it compiles. public class Lab11 { public
I need help with this program please 1. Please copy the following code into your IDE and ensure it compiles.
public class Lab11 { public static void main(String[] args) {
int[] array = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; } }
2. Make a method to print an array that accepts the array and the length of the array as parameters. (Is the length necessary? If you want, modify your code to work without having to accept the length.) Test your method with the given array.
3. Make a method that accepts an array and a new element, which adds that element to the array. You want to go through the array until you find a -1, then replace the first -1 you run into with the new element. Return/print something appropriate if the array is full.
4. Make a method that inserts a certain value to a specific index in the array (accepts array, new value, and index.) Check if index is within range before you attempt to insert it.
5. Make a method that deletes the value of a specific index from the array (turn it back to -1) this one accepts the array, and index to delete. Check if index is within range before you attempt to delete the value in it.
6. Create a 2D Array (10x10) where you will be storing values of type int, fill in the elements of the 2d array by prompting the user for input. 7. Create a method that accepts a 2d array and prints it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started