Question: Describe what the following program does and explain how it does it. import java.nio.DoubleBuffer; public class Temperatures { public static void main(String[] args) { double[]

Describe what the following program does and explain how it does it.

import java.nio.DoubleBuffer; public class Temperatures { public static void main(String[] args) { double[]

import java.nio.DoubleBuffer; public class Temperatures { public static void main(String[] args) { double[] temps = new double[] { 63, 61.5, 59, 58.2, 57, 57.6, 58.3, 61, 63, 65.5, 68, 72, 76.5, 79, 82, 83.5, 81.7, 79.3, 77, 75.2, 73, 70.4, 68, 66.5); Double Buffer tempBuf = DoubleBuffer.wrap(temps); int capacity tempBuf.capacity(); Double Buffer tempBuf2 = Double Buffer.allocate (capacity); tempBuf.position (capacity / 2); while (tempBuf.position () < capacity) { } = tempBuf2.put(tempBuf.get()); tempBuf.rewind(); tempBuf.limit (capacity / 2); while (tempBuf.position() < tempBuf.limit()) { tempBuf2.put(tempBuf.get() + 2.0); } temps tempBuf2.array(); for (double temp: temps) { = System.out.print(temp + " "); } } // end main } // end Temperatures class

Step by Step Solution

3.36 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The provided Java program is a simple commandline application that takes a static array of double values which seem to represent temperature readings ... View full answer

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 Introduction To Programming With Java A Problem Solving Approach Questions!