Describe what the following program does and explain how it does it. import java.nio.DoubleBuffer; public class Temperatures
Question:
Describe what the following program does and explain how it does it.
Transcribed Image Text:
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
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (1 review)
The provided Java program is a simple commandline application that takes a static array of double values which seem to represent temperature readings ...View the full answer
Answered By
CHARLES AMBILA
I am an experienced tutor with more than 7 years of experience. I have helped thousands of students pursue their academic goals. My primary objective as a tutor is to ensure that students have easy time handling their academic tasks.
5.00+
109+ Reviews
323+ Question Solved
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted:
Students also viewed these Computer science questions
-
Explain the meaning of the terms emoluments, employments and office for the purposes of PAYE as you earn systems. 2. Explain the actual receipts basis of assessing the emoluments from the employment...
-
How do Porter's competitive forces model, the value chain model, synergies, core competencies, and network-based strategies help companies use information systems for competitive advantage? a. Define...
-
Access the annual financial statements of Empire Company Limited for its year ended May 2, 2015 at www.sedar.com or the company's website. Instructions Review Empire Company Limited's consolidated...
-
Northwest Building Products (NBP) manufactures two lumber products from a joint milling process: residential building lumber (RBL) and commercial building lumber (CBL). A standard production run...
-
A 200-m-wide river flows due east at a uniform speed of 2.0 m/s. A boat with a speed of 8.0 m/s relative to the water leaves the south bank pointed in a direction 30o west of north. What are the (a)...
-
How can you use future value and present value computations to measure the opportunity cost of a financial decision?
-
Plaintiffs purchased stock warrants (rights to purchase) for blocks of Osborne Computer Corp., the manufacturer of the first mass-market portable personal computer. Because of inability to produce a...
-
Condensed balance sheet and income statement data for Clarence Corporation appear below and on page 696. Additional information: 1. The market price of Clarence's common stock was $4.00, $5.00, and...
-
How might actions/events in other countries outside the U.S. effect the aggregate supply or aggregate demand in the U.S.? Be sure to explain.
-
Indicate the modifications youd need to make to the code in the previous exercise if you want tempBuf2 to be a ByteBuffer instead of a Doublebuffer. Assume that tempBuf continues to be a...
-
Modify this chapters WebPageReader program to read a web page through a buffer. Instead of importing InputStream, import BufferedReader and InputStreamReader. Instead of: use: And instead of: use:...
-
In Exercises 714, simplify each rational expression. Find all numbers that must be excluded from the domain of the simplified rational expression. 4x - 8 2 - 4x + 4 +
-
Name 25 points Class: Time: (In: criticalperiodtstla.ws) PLEASE read all questions in this document The assignment is presented to stimulate critical thinking skills towards information presented in...
-
When would a preferred stock with a stated maturity most likely see its largest decline in price? Select answer from the options below Never, as a stated maturity date for preferred stock is not...
-
Buttery Ice-Cream had sales of $7.25 million in 2020. Its cost of goods sold was $4.5 million, and it had $1.2 million in selling, general, and administrative expenses. It paid interest of $21000 and...
-
what are some financial measurement tools that an investor can use to make a sound decision?
-
Providers in capitated managed care plans who are paid flat monthly fees
-
Portsmouth Port Services creates and maintains shipping channels at various ports around the world. The company is considering the purchase of a $72,000,000 ocean-going dredge that has a 5-year life...
-
Why is homeostasis defined as the "relative constancy of the internal environments? Does negative feedback or positive feedback tend to promote homeostasis?
-
Growth accounting The appendix to this chapter shows how data on output, capital, and labor can be used to construct estimates of the rate of growth of technological progress. We modify that approach...
-
Toby has opened an RRSP account by making an initial deposit of $1200. She intends to make quarterly deposits for 20 years, increasing at a constant rate of 1.5%. How much of the accumulated value...
-
Which contains information about 36 jars of salsa available at the Meals for Millions Food Pantry. If a jar is randomly selected, determine the probability that the salsa is not a medium salsa. Write...
-
How do relational database management systems optimize storage and retrieval operations through the implementation of various table indexing techniques, including B-trees, hash indexes, and bitmap...
-
Write an expression that produces a given resultant vector. a) Write an expression that can be used to produce vector b from vector a, and explain how you determined that expression. (4 points) y 8...
-
In this FNT you will combine process a) and processes c)-d) in one Temperature vs. Energy Added diagram. a) Sketch a Temperature vs. Energy Added diagram for sodium acetate going between room...
Study smarter with the SolutionInn App