Question: Please help me with my computer science lab, thanks a lot . Please copy the following code into your IDE and ensure it compiles. public
Please help me with my computer science lab, thanks a lot
. Please copy the following code into your IDE and ensure it compiles. public class Lab10
{
public static void main(String[] args)
{
int[] array = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int i =3;
System.out.println(the+ i + element value in your arrays is: + array[i]);
}
}
Print the given array. You want to use a loop that goes through all elements in the array to avoid typing out the print statements for every element. Note: your loop should be still reusable even you change the length of the array.
Use a loop to keep accepting positive values from the user and fill out the array using those values. For every new input, go through the array until you get -1, then replace the first -1 with the new value, in this way you will change the value in sequence by checking all elements and replace the value when getting -1 [Remember: array is positive means all elements positive].
Now, accept new value and new index from the user to change the value of the element of that index to the new value. Check if the index is within the range (length) of your array before you attempt to insert a new value.
Accept an index from the user and delete the value for that index (Note: change the value back to -1). Check if the index is within the range (length) of your array before you attempt to delete the value in the array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
