2. Replace (????) with relevant code for the program to function. Details about the programs are provided below. (Jav has been used)
2. Replace (????) with relevant code for the program to function. Details about the programs are provided below. (Jav has been used)
a)This program prints four lines:
kimarr() 4 [9, 0, 0, 14]
2 [9, 0, 0, 14]
kimarr() 8 [9, 9, 14, 14]
4 [9, 9, 14, 14]
*/
package finalexamtakehome2;
import java.util.*; // for Arrays class
/**
*
* @author sweetkim
*/
public class Finalexamtakehome2 {
//
public static void kimarr(int x, int[] a) {
x = x * 2;
if (x > 6) {
a[2] = 4;
a[1] = 9;
} else {
a[0] = 9;
a[3] = 1;
}
System.out.println("kimarr() " + x + " " + Arrays.toString(????));
}
//
public static void main(String[] args) {
int x = 1;
int[] a = new int[4];
x = x * ????;
kimarr(x, a);
System.out.println(x + " " + Arrays.toString(????));
x = x * 2;
kimarr(x, a);
System.out.println(x + " " + Arrays.toString(????));
}
}
/*
b) This program displays
retval = 3
*/
package finalexamtakehome3;
/**
*
* @author sweetkim
*/
public class Finalexamtakehome3 {
//
public static int howMany(????) {
int count = 1;
int maxCount = 1;
int howManyTimes = a[0];
for (int i = 0; i < a.length - 1; i++) {
if (a[i] = a[i + 1]) {
count++;
if (count maxCount) {
howManyTimes = a[z];
maxCount = count;
}
} else {
count = 1;
}
}
???? howManyTimes;
}
//
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//
int retval;
int [] argArray = {3, 4, 3, 5, 7, 6, 7, 1};
????Finalexamtakehome3.howMany(argArray);
System.out.println("retval = " + retval);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps