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)...
-
Latisha is an unmarried taxpayer, filing head of household. She has two dependent children (7-year-old twins) who lived with her all year. Her 2016 earned income was $18,600, her AGI was $22,700, and...
-
Calculate the following: 1. \(3.8 \times 10^{-3}+1.006 \times 10^{-3}\) 2. \(9.61 \times 10^{8}-3.85 \times 10^{8}\)
-
Milano Corporation has three operating divisions and requires a 12% return on all investments. Selected information is presented here: Required: a. Calculate the missing amounts for each division. b....
-
. Bridgeport Inc. issues 4,150 shares of $100 par value preferred stock for cash at $135 per share. Journalize the issuance of the preferred stock. (List all debit entries before credit entries....
-
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:...
-
Your pharmaceutical firm is seeking to open up new international markets by partnering with various local distributors. The different distributors within a country are stronger with different market...
-
Why may the auditor specify different detection risks for different substantive tests of the same assertion?
-
A four-year corporate bond with a 7% coupon has a Z-spread of 200 bps. Assume a flat yield curve with an interest rate for all maturities of 5% and annual compounding. The bond will most likely sell:...
-
As lower acceptable levels of both audit risk and materiality are estab- lished, the auditor should plan more work on individual accounts to a. Find smaller errors. b. Find larger errors. c. Increase...
-
What purposes are served by audit programmes?
-
What is the difference between preliminary audit strategies and planned substantive procedures?
-
SFAS No. 158 no longer allows companies to report the SFAS No. 87 minimum liability in the balance sheet. Instead, the amount reported in the balance sheet is measured using projected benefits rather...
-
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...
-
cet (a) bo a function with f'(2) 0. Which of the following must be from about f The tangent line to the graph of fat (2. f(2)) is horizontal. Of has a local maximum or a local minimum at (2, f(2))...
-
1. Determine the standard temperature at any altitude.. 2. What "sphere/pause" has the coldest temperatures? .. Chapter 3 3. "From Hot to Cold and High to Low look out below." What is 'true' altitude...
-
of 21 > Macmillan Learning Suppose rubber prices rise in international markets. For countries that import rubber, this scenario would lead to: demand-pull inflation. an increase in potential output....
Study smarter with the SolutionInn App