this is a while array mystery from java. please help me to write
the code for this question to run it on eclipse !! I want the full
code to run this program !!![Consider the following method: public static void arrayMystery (int[] a) { for (int i = a. length - 1; i >= 1; i--) { if (a[i](http://img.homeworklib.com/questions/0ccf5290-44f9-11eb-bddf-ad5410cd0f22.png?x-oss-process=image/resize,w_560)
program Screen Shot:

![public static void main(String[] args) { //original contents of array & also showing after passing them to arrayMystery int[]](http://img.homeworklib.com/questions/55096490-44f9-11eb-a651-25be4fc283de.png?x-oss-process=image/resize,w_560)
![int[] a3 = {5, 10, 20, 35, 40}; System.out.println(\noriginal contents of Array a3:); printArray(a3); arrayMystery(a3); Sys](http://img.homeworklib.com/questions/557b1f00-44f9-11eb-b989-2dcc4a7b61d7.png?x-oss-process=image/resize,w_560)
Sample
output:



Program code to copy:
public class ArrayContents {
//A method named 'arrayMystery' which is already given in statement
public static void arrayMystery(int[] a){
for(int i= a.length - 1; i >=1 ; i--){
if(a[i] > a[i-1]+10){
a[i-1] = a[i-1] + 5;
}
}
/* Lets do its dry run of array a1
i=3-1 = 2 ; 2>=1 is true------if(a[2] > a[1]+10) --> if(99 > 42+10) which is true, so a[1] = a[1] + 5 -->42+5 = 47
then i--; --> i = 1 ---- 1>=1 is true so , if(a[1] > a[0]+10) --> if(47 > 42+10) which is false
then again i--; --> i = 0; 0>=1 is false so terminate the loop
------> Lastly We have a[0] =42 which is unchanged , a[1] = 47 changed in first iteration above , a[2] = 99 unchanged
*/
}
public static void main(String[] args) {
//original contents of array & also showing after passing them to arrayMystery
int[] a1 = {42 , 42 , 99};
//Showing original contents
System.out.println("Original contents of Array a1:");
printArray(a1);
//Calling arrayMystery with a1 as parameter
arrayMystery(a1);
//After that printing the the contents
System.out.println("\nFinal contents of Array a1:");
printArray(a1);
//Doing above for all the next Arrays
int[] a2 = {6, 18, 4, 25};
System.out.println("\nOriginal contents of Array a2:");
printArray(a2);
arrayMystery(a2);
System.out.println("\nFinal contents of Array a2:");
printArray(a2);
int[] a3 = {5, 10, 20, 35, 40};
System.out.println("\nOriginal contents of Array a3:");
printArray(a3);
arrayMystery(a3);
System.out.println("\nFinal contents of Array a3:");
printArray(a3);
int[] a4 = {-20, 20, 26, 32, 50, 3};
System.out.println("\nOriginal contents of Array a4:");
printArray(a4);
arrayMystery(a4);
System.out.println("\nFinal contents of Array a4:");
printArray(a4);
int[] a5 = {5, 10, 16, 21, 27, 40, 55};
System.out.println("\nOriginal contents of Array a5:");
printArray(a5);
arrayMystery(a5);
System.out.println("\nFinal contents of Array a5:");
printArray(a5);
}
//Instead of using loop multiple times, lets define a method which would take array as passed argument & prints its values
public static void printArray(int[] arr){
for (int i=0; i<arr.length; i++){
System.out.println(+arr[i]);
}
}
}
-------------------------------
COMMENT DOWN FOR ANY QUERIES........
HIT A THUMBS UP IF YOU DO LIKE IT!!
this is a while array mystery from java. please help me to write the code for...
Someone help please Let A be an array of 5 integers, whose contents are as follows: 3, 2, 1, 5, 4 We will apply quick sort to sort this array. Show all of the element-wise comparisons made by the algorithm in the correct order. Here an element-wise comparison means the comparison of one element of the array with another element of the array or the key set in a particular step of the algorithm. Since the algorithm may move the...
in java please fix code between
14 and 20 to make the code compile
Write a method swapArrayEnds() that swaps the first and last elements of its array parameter. Ex: sortArray = {10, 20, 30, 40} becomes {40, 20, 30, 10). The array's size may differ from 4. Display ari ay Values 1 pas [ pa: 6 public void displayValues(int [] arrayVals) { 7 int i; 8 9 for (i = 0; i < arrayVals.length; ++i) { 19 System.out.print(arrayVals[i] +...
Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish. algorithm (either flowchart or pseudocode) that you will use to write the program Step 1. Create an Place the algorithm in a Word document. 6. Ste the Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1....
23.1 Append to Oversize Array Java Help Given an oversize array with size1 elements and a second oversize array with size2 elements, write a method that returns the first array with the elements of the second appended to the end. If the capacity of the oversize array is not large enough to append all of the elements, append as many as will fit. Hint: Do not construct a new array. Instead, modify the contents of the oversize array inside the...
Array manipulation (a) Write Java code for a method exchange (int [] a, int i, int j) that exchanges the values stored at indices i and j in the array a. You do not need to worry about cases where either i or j is an invalid index. Give the best estimate you can for its time complexity (b) In an ordered array of n items, how can we determine whether or not an item belongs to the list using...
Please write where its written write your code here!! please use java for the code! please use the given code and I will rate thanks Magic index in an array a[1..n] is defined to be an index such that a[ i ] = i. Given an array of integers, write a recursive method to find the first magic index from left to right. If one exists in the given array, return the index number i, otherwise return -1. Here are...
Arrays and Methods Worksheet 2 (10 pts) Copy the following into a new file called ArrayMethods2.java. Write the methods one-by-one. Compile and run your code after you write each method to make sure it was written properly. When your methods pass all of the tests, upload your file to Canvas. /** * Assignment 20.2 * @author Your Name * CIS 36A */ public class ArrayMethods2 { /** * Given an array of ints, return the index of the...
Java question
Given an array of integer numbers, write a linear running time complexity program in Java to find the stability index in the given input array. For an array A consisting n integers elements, index i is a stability index in A itf ATO] + A[1] + +A[iI-1] Ali+1]+ Ali+2] +... + A[n-1]; where 0 <i< n-1 Similarly, 0 is an stability index if (A[1] A[2]A[n-1]) 0 and n-1 is an stability index if (A[0] A[1]+... A[n-21) 0 Example:...
It's been too long since I have done any Java programming. Can anyone help me with this one? Thank you 6.5 Write the declaration for a class named C that declares: (1) a private int instance variable named mX; (2) a private int class variable named mY initialized to 0; (3) a private int class constant named A which is equivalent to 100; (4) a public int class constant named B which is equivalent to 200; (5) public accessor and...
Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...