Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am writing Java code using a website called CodeLab and it will not acc

ID: 3627156 • Letter: H

Question

Hello, I am writing Java code using a website called CodeLab and it will not accept my answers for the following questions: Any help is appreciated!

1) Given that an array named a whose elements are of type int has been declared, assign the value
          -1
to the last element in a .

2) Assume that an array of int s named a has been declared with 12 elements. The integer variable k holds a value between 0 and 6 . Assign 15 to the array element whose index is k .

3) An array of int s named a has been declared with 12 elements. The integer variable k holds a value between 0 and 6 . Assign 9 to the element just after a[k] .

4) An array of int s named a has been declared with 12 elements. The integer variable k holds a value between 2 and 8 . Assign 22 to the element just before a[k]

5) Declare an array reference variable, week, and initialize it to an array containing the strings "mon", "tue", "wed", "thu", "fri", "sat", "sun" (in that order).

Explanation / Answer

1) Given that an array named a whose elements are of type int has been declared, assign the value
          -1
to the last element in a .

a[a.length()-1] = -1

2) Assume that an array of int s named a has been declared with 12 elements. The integer variable k holds a value between 0 and 6 . Assign 15 to the array element whose index is k .

s[k]= 15

3) An array of int s named a has been declared with 12 elements. The integer variable k holds a value between 0 and 6 . Assign 9 to the element just after a[k] .

a[k+1]=9

4) An array of int s named a has been declared with 12 elements. The integer variable k holds a value between 2 and 8 . Assign 22 to the element just before a[k]

a[k-1]=22

5) Declare an array reference variable, week, and initialize it to an array containing the strings "mon", "tue", "wed", "thu", "fri", "sat", "sun" (in that order).

String[] week=new String[]{"mon", "tue", "wed", "thu", "fri", "sat", "sun"};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote