Double any element's value that is less than minValue. Ex: If minValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4, 12, 18, 20}.
import java.util.Scanner;
public class StudentScores {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_Points = 4;
int[] dataPoints = new int[NUM_POINTS];
int minValue;
int i;
minValue = scnr.nextInt();
for (i = 0; i < dataPoints.length; ++i) {
dataPoints[i] = scnr.nextInt();
}
/* Your solution goes here */
for (i = 0; i < dataPoints.length; ++i) {
System.out.print(dataPoints[i] + " ");
}
System.out.println();
}
}

Answers

Answer 1

Answer:

Following are the code to this question:

for(i=0;i<dataPoints.length;++i) //define loop to count array element  

{

if(dataPoints[i]<minValue) // define condition that checks array element is less then minValue

{

dataPoints[i] = dataPoints[i]*2; //double the value

}

}

Explanation:

Description of the code as follows:

In the given code, a for loop is declared, that uses a variable "i", which counts all array element, that is input by the user. Inside the loop and if block statement is used, that check array element value is less then "minValue", if this condition is true.  So, inside the loop, we multiply the value by 2.

Related Questions

Trace the complete execution of the MergeSort algorithm when called on the array of integers, numbers, below. Show the resulting sub-arrays formed after each call to merge by enclosing them in { }. For example, if you originally had an array of 5 elements, a = {5,2,8,3,7}, the first call to merge would result with: {2, 5} 8, 3, 7 ← Note after the first call to merge, two arrays of size 1 have been merged into the sorted subarray {2,5} and the values 2 and 5 are sorted in array a You are to do this trace for the array, numbers, below. Be sure to show the resulting sub-arrays after each call to MergeSort. int[] numbers = {23, 14, 3, 56, 17, 8, 42, 18, 5};

Answers

Answer:

public class Main {

public static void merge(int[] arr, int l, int m, int r) {

int n1 = m - l + 1;

int n2 = r - m;

int[] L = new int[n1];

int[] R = new int[n2];

for (int i = 0; i < n1; ++i)

L[i] = arr[l + i];

for (int j = 0; j < n2; ++j)

R[j] = arr[m + 1 + j];

int i = 0, j = 0;

int k = l;

while (i < n1 && j < n2) {

if (L[i] <= R[j]) {

arr[k] = L[i];

i++;

} else {

arr[k] = R[j];

j++;

}

k++;

}

while (i < n1) {

arr[k] = L[i];

i++;

k++;

}

while (j < n2) {

arr[k] = R[j];

j++;

k++;

}

printArray(arr, l, r);

}

public static void sort(int[] arr, int l, int r) {

if (l < r) {

int m = (l + r) / 2;

sort(arr, l, m);

sort(arr, m + 1, r);

merge(arr, l, m, r);

}

}

static void printArray(int[] arr, int l, int r) {

System.out.print("{");

for (int i = l; i <= r; ++i)

System.out.print(arr[i] + " ");

System.out.println("}");

}

public static void main(String[] args) {

int[] arr = {23, 14, 3, 56, 17, 8, 42, 18, 5};

sort(arr, 0, arr.length - 1);

}

}

Explanation:

See answer

Other Questions
A researcher attempts to use a segment of ribosomal RNA as a molecular clock to calculate the date of the last common ancestor of two species. He finds that the two species diverged from a common ancestor 150 million years ago. These particular species have abundant fossil records that strongly suggest that these species diverged 100 million years ago. Which of the following answer choices best describes a reason for the discrepancy in the date of the last common ancestor of these species?A. Ribosomal RNA is not a reliable molecular clock and should not be used for dating.B. The neutral mutation rate used in calculating the last common ancestor date may not have been accurate.C. It is highly likely that the two organisms did not share a common ancestor, so the results are invalid.D. A large portion of the ribosomal RNA is not vital to survival, so it is not likely to be well preserved. What was Simon Wiesenthal's nickname I really need help with this :(( how are a common denominator and a common multiple alike and diferent 1. En grupo, con la coordinacin de su maestra o maestro, realicenlo siguiente.Lean el objetivo del diagnstico, las fuentes de informacin sugeridas y los ins-trumentos para recolectarla. Anoten en su cuaderno otras fuentes de informa-cin y otras acciones para recolectarla. You have ten pigeons. You want to give these pigeons away to some of your friends. The first friend picks a number of pigeons of her choice for herself. After that you give away the remaining pigeons to the rest of your friends. If you give each of them 3 pigeons, 5 are left and if you give each of them 5 pigeons, 3 are left. How many pigeons did your first friend choose for herself? What disadvantages might being nonaligned have offered a developing nation during the Cold War? Relate dark matter to the development of the universe after the Big Bang. In 3-5 sentences, speculate on how the development of the universe would have been different if there had been no dark matter. In your answer, use the term structures.Please answer if you do i will mark you as brainliest The Spanish Armada was defeated becauseA. Spain had smaller ships than EnglandB. English sailors were clever fightersC. bad storms destroyed Spanish shipsD. a combination of b and cE. the Spanish were not good fighters Mi abuela nos pidi que nosotros nocon la boca llena. (hablar)O hablarhablemoso hablramoshablan There different ways to think about 1 3/8- 1/1/8. Select three ways to find it ellusWhat is the pH of a 3.5 x 10-11 MH+ solution?pH = [?] tan(-20) = _____. -tan 20 tan 20 tan (-160) -tan 160 Information related to the organisms found on Earth duringvarious geological time periods is represented in the accompanyingchart.OOEEOC 0-0 C-E2525-Edw-4.6 (?) Billion600 Million200 Million60 MillionYears AgoYears AgoYears Ago Years AgoPrecambrianPaleozoicMesozoic Cenozoic(Simple(Age of Amphibians, Fishes, (Age of Reptiles) (Age ofMulticellularand Invertebrates)Mammals)a organisms andFirst Protists)PastPresentGeologic TimeWhich statement concerning the first appearance of the organismsover the time period represented in this chart is most likelycorrect? Hook for French Revolution anyone ? which phase does best describe the side of the moon that faces earth???I WILL MARK BRAINLIEST THIS IS IMPORTANT What is the molarity of a solution inwhich 3.8 moles of sodium chloride(NaCl) is dissolved in water to a finalvolume of 2.5 L? 1. What was the fear that if one Asian nation fell to communism, others would soon follow? *10 points-domino theory-topple effect-falling democracy-collapsing countries2. The "Iron Curtain" was a term used to describe the division between what two political areas? *10 points-East and West Europe-North and South Vietnam-North and South Korea-East and West Africa true or false: part of hitlers plan to invade the soviet union included building bases in the balkans During the Civil War, which leader often had fewer troops available for battle?A.George McClellanB.Robert E. LeeC.Jefferson DavisD.Winfield Scottplease help asap