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

(Basic Java; Arrays and the ArrayList Class) ~ Find The Error ~ #1) int[] collec

ID: 3565110 • Letter: #

Question

(Basic Java; Arrays and the ArrayList Class)


~Find The Error~

#1) int[] collection = new int[-20];

#2) int[] hours = 8, 12, 16;

#3) int[] table = new int[10];

   ~AlgorithmWorkbench~


#1) The variable names references an integer array with 20 elements. Write a for loop that
prints each element of the array.

#2) The variables numberArray1 and numberArray2 reference arrays that each have 100
elements. Write code that copies that values in numberArray1 to numberArray2.

#3) In a program you need to store the identification numbers of ten employees (as int
values) and their weekly gross pay (as double values).

-A. Define two arrays that may be used in parallel to store the 10 employee identification
numbers and gross pay amounts.
-B. Write a loop that uses these arrays to print each of the employees' identification
number and weekly gross pay.

----------------------------------^^^^^------------------------------------------------

^Top^ questions are Priority, if you can please help me on thisas well ( Time limit for this part is 1 week )

#1)   


Write a RainFall class that stores the total rainfall for each of 12 months into an array of
doubles. The program should have methods that return the following:

Explanation / Answer

~Find The Error~

#1) int[] collection = new int[-20];

we cannot give negative size for an array.. so that it will give "NegativeArraySizeException".

#2) int[] hours = 8, 12, 16;

To store values in array we have to declare as following :
int[] hours = {8,12,16};

3) int[] table = new int[10];

It works fine.. there is no error in this statement

~AlgorithmWorkbench~

#1) The variable names references an integer array with 20 elements. Write a for loop that
prints each element of the array.

for(int i = 0; i < 20; i++)
System.out.println(names[i]);


#2) The variables numberArray1 and numberArray2 reference arrays that each have 100
elements. Write code that copies that values in numberArray1 to numberArray2.

for(int i = 0; i < 100; i++)
numberArray2[i] = numberArray[i];


#3) In a program you need to store the identification numbers of ten employees (as int
values) and their weekly gross pay (as double values).

-A. Define two arrays that may be used in parallel to store the 10 employee identification
numbers and gross pay amounts.

int[] employees = new int[10];
double[] grosspay = new double[10];


-B. Write a loop that uses these arrays to print each of the employees' identification
number and weekly gross pay.

for(int i = 0 ; i < 10; i++)
System.out.println(employees[i] + " " + grosspay[i]);