Integer numPoints is read from input, representing the number of floating-point numbers to be read next....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Integer numPoints 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 pointsArray. Initialize the array halfArray to be half the size of pointsArray. Write a loop that iterates through halfArray and: • If the corresponding element in the second half of pointsArray is greater than 85.0, then assign the element in halfArray with 0.0. • Otherwise, assign the element in halfArray with the corresponding element in the second half of points Array. Ex: If the input is: 4 72.5 105.0 82.5 92.5 then the output is: Original points: 72.5 105.0 82.5 92.5 Second half of the points: 82.5 0.0 Note: Input array always has an even number of elements. 1 import java.util.Scanner; 2 3 public class Points { 4 5 6789 9 10 11 12 13 14 15 16 17 755 public static void main(String[] args) { Scanner scnr new Scanner (System.in); double[] pointsArray; double [] halfArray; int numPoints; int i; numPoints scnr.nextInt(); pointsArray = new double [numPoints]; for (i = 0; i < pointsArray.length; ++i) { pointsArray[i] = scnr.nextDouble(); } 16 17 18 19 20 21 22 23 24 25 25 27 28 29 30 31 32 33 26 33 3 } pointsArray[i] = scnr.nextDouble(); } /* Your code goes here */ System.out.print("Original points: "); for (i = 0; i < pointsArray.length; ++i) { System.out.printf("%.1f ", pointsArray[i]); } System.out.println(); System.out.print("Second half of the points: "); for (i = 0; i < halfArray.length; ++i) { System.out.printf("%.1f ", halfArray[i]); } System.out.println(); 4 Integer numPoints 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 pointsArray. Initialize the array halfArray to be half the size of pointsArray. Write a loop that iterates through halfArray and: • If the corresponding element in the second half of pointsArray is greater than 85.0, then assign the element in halfArray with 0.0. • Otherwise, assign the element in halfArray with the corresponding element in the second half of points Array. Ex: If the input is: 4 72.5 105.0 82.5 92.5 then the output is: Original points: 72.5 105.0 82.5 92.5 Second half of the points: 82.5 0.0 Note: Input array always has an even number of elements. 1 import java.util.Scanner; 2 3 public class Points { 4 5 6789 9 10 11 12 13 14 15 16 17 755 public static void main(String[] args) { Scanner scnr new Scanner (System.in); double[] pointsArray; double [] halfArray; int numPoints; int i; numPoints scnr.nextInt(); pointsArray = new double [numPoints]; for (i = 0; i < pointsArray.length; ++i) { pointsArray[i] = scnr.nextDouble(); } 16 17 18 19 20 21 22 23 24 25 25 27 28 29 30 31 32 33 26 33 3 } pointsArray[i] = scnr.nextDouble(); } /* Your code goes here */ System.out.print("Original points: "); for (i = 0; i < pointsArray.length; ++i) { System.out.printf("%.1f ", pointsArray[i]); } System.out.println(); System.out.print("Second half of the points: "); for (i = 0; i < halfArray.length; ++i) { System.out.printf("%.1f ", halfArray[i]); } System.out.println(); 4
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
A rectangular loop of wire with sides 0.20 and 0.35 m lies in a plane perpendicular to a constant magnetic field (see part a of the drawing). The magnetic field has a magnitude of 0.65 T and is...
-
Payables Period why dont all firms simply increase their payables periods to shorten their cash cycles?
-
Analysts following the Tomkovick Golf Company were given the following information for the years ended June 30, 2013 and June 30 2012: Construct a 2013cash flow statement for this firm. Calculate the...
-
Explain the various refrigerants used in refrigeration and air conditioning.
-
Westbrook Co. predicts that it will use 225,000 gallons of material during the year. The material is expected to cost $10 per gallon. It anticipates that it will cost $40 to place each order. The...
-
Name four characteristics of Force?
-
What Happens When You Dont Deliver on Your Promises Web: www.clearly.ca Facebook: Clearly Canadian If a new product or service seems like the perfect option to solve a problem or capitalize on an...
-
The Senbet Co. had gross sales of $1 million. Its cost of goods sold and administrative expenses were $300,000 and $200,000 respectively. Senbet also had bond debt of $1 million on which the interest...
-
Let quantity demanded be given by Qd=101-0.8P and quantity supplied be given by Qs=23+1.3P. If there is a quota of 14, then what will be the domestic price? Round answers to two decimal places.
-
Four years ago Jensen Inc. had purchase equipment for $2,100,000. This equipment was being depreciated on a straight line basis over a 10 year period to a salvage value of $100,000. The equipment has...
-
George Oscar Bluth (GOB) presents a business proposal to his mother, Lucile Bluth. GOB wants to start a magician troupe that performs around Orange County, California. GOB would like a loan of...
-
Output per Worker per Day Computers Steel Unskilled worker 1 4 Skilled worker 3 6 What is the minimum no. of units of steel a skilled worker will accept to trade away 1 computer?
-
How would you define the sales behavior of a constructing company that in their finance statements had a sales value of 264,327,579 colones, with 0 discounts or returns and where operational costs...
-
Rothbart Manufacturing agrees to manufacture bumper cars for Banners Amusement Parks. Under the terms of the contract, Banners will pay Rothbart a total of $64,000, and Banners can cancel the...
-
Suppose that a company has 10.000 outstanding shares in the beginning of the year. On April 1st, the company increases its shares by 6.000. On July 1st, the company increases its shares again, but...
-
The function judge() has a type int return value. As an argument, it takes the address of a function. The function whose address is passed, in turn, takes a pointer to a const char as an argument and...
-
Listing 15.16 uses two catch blocks after each try block so that the nbad_index exception leads to the label_val() method being invoked. Modify the program so that it uses a single catch block after...
-
Put together a program that keeps track of monetary contributions to the Society for the Preservation of Rightful Influence. It should ask the user to enter the number of contributors and then...
-
A leading financial publication reported that the average baby boomer credit user will pay approximately $1,200 in interest annually. If, instead of paying interest, this amount was saved every year,...
-
With the availability of free credit reports, consumers are encouraged to check their report every 4 months-one report from each of the three major bureaus. In the past, consumers also were...
-
Some credit card issuers are beginning to assess fees and other charges on convenience users. Ask your friends and peers if they think a convenience credit card user should be charged for the...
Study smarter with the SolutionInn App