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):
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.)
//   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
Make a C++ program that outputs these following numbers: 10 5 9 10 8 15 7...
Make a C++ program that outputs these following numbers: 10 5 9 10 8 15 7 20 6 25 Please do not use functions. Only use while loop. Thank you :)
Year 1 2 3 4 5 6 7 8 9 10 A 1 1.01 1.0201 1.0303...
Year 1 2 3 4 5 6 7 8 9 10 A 1 1.01 1.0201 1.0303 1.0406 1.0510 1.0615 1.0721 1.0829 12.0305 B 1 .9900 .9801 .9703 .9606 .9510 .9415 .9321 .9227 10.0487 Assume a purchase price of $10 Million for both properties. (a) What is the expected total return (IRR) on a 10-year investment in each property? Use a financial calculator or equation solver for this. (b) If the 10% cap rate represents a fair market value for each...
Array indices must be positive integers or logical values?
How can I fix this MATLAB error Index in position 2 is invalid. Array indices must be positive integers or logical values?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT