Chapter 9, 9.6

1. What are parallel arrays?– They are arrays that contains corresponding data in cells of same index. 2. Describe an application in which parallel arrays might be used.– The declaration between people’s name and their age in the school. 3. Declare an instantiate the variables for parallel arrays to track the names, ages, and social security numbers of 50 employees.String [] name = new String[50]int [] age = new int [50]int [] security = new int [50]String searchPerson;int correspondingAge = -1, correspondingSecurity = -1searchName = …for (int i = 0, i<name.length; i ++) if (searchName.equal (name[i]))correspondingAge = age [i]correpondingSecurity = security [i]break;}. 5. Write a code segment that creates parallel arrays containing the first 10 nonnegative powers of 2. One array should contain the exponent and the other array should contain 2 raised to that power.

– int[] exponent = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

int[] powers = new int[10];

for (int i = 0; int < 10; i++){

power [i] = math.pow(2, exponent[i])

} ;

Leave a Comment