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)...
-
Why is the liabilities section of the balance sheet of primary significance to bankers?
-
The following table presents residual heat flows in the enthalpy cascade of a process computed at \(\Delta T_{\text {min }}=10^{\circ} \mathrm{C}\) (Smith, 2005): (a) It is desired to efficiently...
-
Neveready Flashlights Inc. needs $340,000 to take a cash discount of 3/17, net 72. A banker will loan the money for 55 days at an interest cost of $10,400. a. What is the effective rate on the bank...
-
Suppose you are tracking objects floating in the ocean. The ocean currents can be variable, so you've modeled the system as a directed graph G, where each vertex representing a region of ocean can...
-
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:...
-
You have decided to set up a web-based business. You have investigated the costs, chosen an ISP, and are ready to get working on your site. Youve heard that a quick way to get your site up and...
-
Choose two countries on two continents other than North America. Research them on sites such as http://www.cyborlink .com and https://www.business.com/articles/so-international...
-
Choose five websites that are possible resources for an upcoming assignment. Evaluate them on the currency, authority, accuracy, and purpose of their information. Consider the following questions and...
-
Interview someone about the composing process(es) they use for on-the-job writing. Questions you could ask include the following: What kind of planning do you do before you write? Do you make lists?...
-
After you have fixed Danas email, answer these questions in an email to your instructor. What revisions did you make? Why? Many grocery stores already contribute to local food pantries. In addition...
-
Interview someone who works in an organization about their on-the-job collaboration activities. Possible questions to ask include the following: How often do you work on collaborative projects? Do...
-
Suppose that you are interested in buying yourself a new computer. Create a cost-benefit analysis that illustrates the return on investment that you would receive from making this purchase....
-
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 can World Taekwondo be useful because, with the recent rise of awareness of bullying in school and online, parents are turning to martial arts to help kids improve their self-confidence and learn...
-
What theory best explains why Chris's brother became so upset when people called Chris a junkie?
-
What are the molecular mechanisms underlying enzyme regulation by cofactors and coenzymes, including metal ions, vitamins, and prosthetic groups, and how do these small molecules modulate enzyme...
Study smarter with the SolutionInn App