Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

(1) What is your current leadership development strategy?

Answered: 1 week ago