Answer:
import java.util.Scanner;
public class numm3 {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_POINTS = 4;
int[] dataPoints = new int[NUM_POINTS];
int controlValue;
int i;
System.out.println("Enter the control Variable");
controlValue = scnr.nextInt();
System.out.println("enter elements for the array");
for (i = 0; i < dataPoints.length; ++i) {
dataPoints[i] = scnr.nextInt();
}
for (i = 0; i < dataPoints.length; ++i) {
System.out.print(dataPoints[i] + " ");
}
System.out.println();
//Doubling elements Less than Control Variable
for (i = 0; i < dataPoints.length; ++i) {
if (dataPoints[i]<controlValue){
dataPoints[i] = dataPoints[i]*2;
}
System.out.print(dataPoints[i] + " ");
}
System.out.println(); } }
Explanation:
See the additional code to accomplish the task in bold
The trick is using an if statement inside of a for loop that checks the condition (dataPoints[i]<controlValue) If true, it multiplies the element by 2