Question

In: Computer Science

1) Define and create an array of integers with the values 5, 7, 8, 9 10,...

1) Define and create an array of integers with the values 5, 7, 8, 9 10, 12 using an initializer list. Print the array. 5.

2) Given the Array below, replace the element at position 3 with the value, 99, using an assignment statement. int [] list = {88, 0, 11, 22, 55, 77}; What is the value of list.length?

Solutions

Expert Solution

Here is code in JAVA:

Question 1:

Code:

public class Array {

public static void main(String[] args) {
int[] list = {5, 7, 8, 9, 10, 12}; // array of integers with the values
//Print the array
for (int i = 0; i < list.length; i++) {
System.out.println(list[i]);
}
}
}

Output:

Question 2:

Code:

public class Array {

public static void main(String[] args) {
int[] list = {88, 0, 11, 22, 55, 77}; // array of integers with the values
list[3] = 99; // replace the element at position 3 with the value, 99
//Print the array length
System.out.println("Length of array is : " + list.length);
}
}

Output:


Related Solutions

Ex 1. Show the contents of the array of integers 5 7 4 9 8 5...
Ex 1. Show the contents of the array of integers 5 7 4 9 8 5 6 3 each time a selection sort changes it while sorting the array into ascending order. Initial array:   5 7 4 9 8 5 6 3 ANSWER (Hint there are 8 lines, Show Array after each selection and swap):
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is...
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is the running time of the insertion sort if both A[1..n/2] and A[n/2+1,n] are also sorted. Justify your answer. 2-illustrate the operation of RADIX-SORT on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, TEA, NOW, FOX. 3-Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3
1) Given the list of integers 1, -2, 3, -6, 7, -8, 9, 10, -11, indexed...
1) Given the list of integers 1, -2, 3, -6, 7, -8, 9, 10, -11, indexed from 1 to 9, the left-to-right linear scan algorithm (O(n) algorithm) will set as candidate start positions for a maximum contiguous sequence the elements at the index positions: (a) 1,3,4,6 (b) 1,3,4,6,9 (c) 1,3,5,7 (d) none of the above 2)The Fibonacci sequence 1,1,2,3, ... can be generated iteratively by starting with the first two (0th and 1st) and generating every subsequent one by adding...
Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0.
This program is for C.Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0. Combine the elements of A + B to create two- dimensional array C = A + B. Display array A, B and C to the screen for comparison. (Note a[0] + b[0] = c[0], a[1] + b[1] = c[1], etc.)
Write a recursive method to sum the values in an array of integers. Create a file...
Write a recursive method to sum the values in an array of integers. Create a file ArraySum.java and add the recursive method public int sumOfArray (). Use the driver class ArraySumDriver.java to populate your array and demonstrate that your method works. ////ArraySumDriver.java/////// public class ArraySumDriver { private final static int ARRAY_SIZE = 6; /** * @param args */ public static void main(String[] args) { int index = 0; Integer[] myArray = new Integer[ARRAY_SIZE]; ArraySum arraySum = new ArraySum(); myArray[index++] =...
//   Given an array of size 9, with the values of 1-9, determine if the array...
//   Given an array of size 9, with the values of 1-9, determine if the array //   is valid or not. //   Display a message stating the row is VALId, or state its INVALID and what //   was the index number that determined the data invalid. // //   Use this java code as a start of your code. //   Test the array data by changing the values. //============================================================================= import java.util.*;    public class Soduko_ValidateRow    { public static void main(String...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question 's scores, If three points were added to every score in this distribution, what would be the new mean? If three points were added to every score in this distribution, what would be the new standard deviation. Remember, you have already calculated population standard deviation in a previous problem. This problem requires two answers.
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we...
Consider the following sorted int array: 1 3 4 5 7 9 10 12 If we search for the key value 10 in the array using the binary search algorithm, what is the sequence of indices that will be accessed in the array? (Hint: For a sublist between index values low and high, the middle index is calculated using: (low + high) / 2. So you need to show the sequence of indices of the middle index in each pass.)...
Write a program in Java to do the following: -Create a one-dimensional array of 7 integers...
Write a program in Java to do the following: -Create a one-dimensional array of 7 integers as follows: Assign {35,20,-43,-10,6,7,13} -Create a one dimensional array of 7 Boolean values as follows: Assign {true,false,false,true,false,true,false} -Create a one dimensional array of 7 floating-point values as follows: Assign {12.0f,1.5f,-3.5f,-2.54f,3.4f,45.34f,22.13f} -Declare sum as integer and set it to 0. -Declare sumf as float and set it to 0.0f. -Use a for loop to go through each element of the Boolean array, and if an...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT