4, a Java) method that receives two parallel arrays containing names of scores.
ID: 3831390 • Letter: 4
Question
4, a Java) method that receives two parallel arrays containing names of scores. local variables students and test to It prints rite Mary.The method header is given. Be sure to declare all System out test scores for all students named you may need static void printscores(stringt names, int[] scores) out println("These are the scores earned by students named Mary"); end method 5.Translate the (Cl functions given here to equivalent Java methods. The Java translation should not have any not need parameters. You can assume the standard imports for Java programs we have been using and do to write those. void printArray(int arrt], int arraysize) e; index for (int index arraysize 1; index printf( Xd index]); printf ("In"); end function void arr[], int arraysize) for (int index e; index arr.length; index arr [index] (index 1) 3; end function lava equivalents static void printArray( end method static void fillArray( end method Page 2 of 2Explanation / Answer
4. static void printScores(String[] names, int[] scores)
{
System.out.println("These are the scores earned by students named Mary");
for(int i = 0; i < names.length; i++)
if(names[i].equals("Mary"))
System.out.print(scores[i] + " ");
System.out.println();
}
5.
static void printArray(int[] arr)
{
for(int index = arr.length - 1; index >= 0; index--)
System.out.print(arr[index] + " ");
System.out.println();
}
static void fillArray(int[] arr)
{
for(int index = 0; index < arr.length; index++)
arr[index] = (index + 1) * 3;
}
Java Keyword:
return Yes.
class No.
else Yes.
int Yes.
final No.
6. The output of the code is:
4 0 0
8 3 0
12 3 2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.