Question: java Integer numValues is read from input, representing the number of floating - point numbers to be read next. Then, the remaining numbers are read

java Integer numValues is read from input, representing the number of floating-point numbers to be read next. Then, the remaining numbers are read and stored into array pointsList. Initialize the array modifiedList to be half the size of pointsList. Write a loop that iterates through modifiedList and assigns each element in modifiedList with the corresponding element in the second half of pointsList. import java.util.Scanner;
public class Points {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
double[] pointsList;
double[] modifiedList;
int numValues;
int i;
numValues = scnr.nextInt();
pointsList = new double[numValues];
for (i =0; i < pointsList.length; ++i){
pointsList[i]= scnr.nextDouble();
}
modifiedList = new double[numValues /2];
for (i =(pointsList.length /2); i < modifiedList.length; ++i){
modifiedList[i]= pointsList[i + pointsList.length /2];
}
System.out.print("Original points: ");
for (i =0; i < pointsList.length; ++i){
System.out.printf("%.1f ", pointsList[i]);
}
System.out.println();
System.out.print("Second half of the points: ");
for (i =0; i < modifiedList.length; ++i){
System.out.printf("%.1f ", modifiedList[i]);
}
System.out.println();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!