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[]](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1704/9/4/9/271659f76173d0321704949268544.jpg)
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
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
Get step-by-step solutions from verified subject matter experts
