so i am working on comparing two arrays based on a users input. One array is an int array, the other is a string. What i want to do is take a users input, compare the input to the first int array, then calculate the element within the same position of the string array. then print out my results based on the second array.
Like below i would input 12 then get bob or 21 then get andrea. Example code below. I have everything up to the comparison of the second array (i have the user input, finding it within the int array – the loop, but i just cant figure out the comparison to the second array)
int[] number = {12, 15, 19, 21}
String[] character = {bob, sally, james, andrea}
would i just compare both the arrays then save it in a new variable:
number = character
then print the new variables value?
thanks for the help. i have been searching everywhere for this one. mainly spend a day and a half on this website.
You do not need to compare anything to the second array: once you have the index of the matching element in the first array, simply use that index against the second array. That’s all there is to it!