The example of Fig. 17.7 summed the triples of the even integers from 2 through 10. We
Question:
The example of Fig. 17.7 summed the triples of the even integers from 2 through 10. We used filter and map in the stream pipeline to demonstrate both in one stream pipeline. Reimplement Fig. 17.7’s stream pipeline using only map (similar to Fig. 17.4).
Fig. 17.7
Fig. 17.4
Transcribed Image Text:
1 // Fig. 17.7: StreamFilterMapReduce.java 2 // Triple the even ints from 2 through 10 then sum them with IntStream. import java.util.stream. IntStream; 3 4 5 6 9 10 [1 12 13 public class StreamFilterMapReduce { public static void main(String[] args) { // sum the triples of the even integers from 2 through 10 System.out.printf( "Sum of the triples of the even ints from 2 through 10 is: %d%n", IntStream.rangeClosed (1, 10) .filter(x -> x % 2 == 0) .map(x -> x * 3) .sum()); 14 15 } } Sum of the triples of the even ints from 2 through 10 is: 90
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 0% (2 reviews)
The question is asking to modify the stream pipeline from Figure 177 so that it no longer uses the f...View the full answer
Answered By
Sumit kumar
I am an experienced online essay writer with a thorough understanding of any curriculum.and subject expert at Chegg for mathematics, CS subjects..
4.90+
5+ Reviews
13+ Question Solved
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Question Posted:
Students also viewed these Computer science questions
-
Answer the following questions with regard to the stream pipeline in Fig. 17.7: a) How many times does the filter operation call its lambda argument? b) How many times does the map operation call its...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Write the dual for each of the following primal problems: (a) Maximize z = - 5x1 + 2x2 Subject to - x1 + x2 - 2 2x1 + 3x2 5 X1, x2 0 (b) Minimize z = 6x1 + 3x2 Subject to 6x1 - 3x2 + x3 2 3x1 +...
-
Explain how you would decide whether to record each of the following expenditures as an asset or an expense. Assume all items are material. (a) Legal fees paid in connection with the purchase of land...
-
A beginning accounting student tried to complete a work sheet for Joyce Lee's Tax Service. The following adjusting entries were to have been analyzed and entered onto the work sheet. The work sheet...
-
At some point for air flow in a duct, \(p=20 \mathrm{psia}, T=500^{\circ} \mathrm{R}\), and \(V=500 \mathrm{ft} / \mathrm{s}\). Can a normal shock occur at this point?
-
A process stream flowing at 35k mol/h contains 15 mole% hydrogen and the remainder 1-butene. The stream pressure is 10.0 atm absolute, the temperature is 50C, and the velocity is 150m/min. Determine...
-
1. The following matrix gives a set of cognate words meaning 'ox' in several dif- ferent languages. Language Word Pronunciation Avestan uxshan uksan Chuvash vgr English OX oks Finnish hrk hrk...
-
Figures 4.8 and 4.10 demonstrated calculating a class average with counter-controlled repetition and sentinel-controlled repetition, respectively. Create a program that reads integer grades and...
-
Modify the Stream example that it uses stream capabilities to display the average Employee salary by department.
-
Find the state machine diagram in the form of Figure 6-29 for a Game of PIG using two dice. Also, add the following rule: If a pair of 1s is rolled, thenthe players total score becomes 0. The two...
-
What is the magnitude of the magnetic force (in N) on a charged particle (Q = 6 mC) moving with a speed of 20 km/s in the positive x direction at a point where Bx = 7.0 T, By = -4.0 T, and B = 3.0 T?...
-
Co There are two charges 23.12 cm apart. One charge is 11.93 X10-6C, while the other is -4.88 X10-6 C. What is the magnitude of the force (in N) on one of the charges? ORN
-
Optimal control is a design approach which is used in many applications including aerospace. In particular, it is considered to be a practical design approach. Recall the main features of optimal...
-
Calculate the displacement and velocity at times of (a) 0.5 s, x= (b) 1 s, x= (c) 1.5 s, x= and (d) 2 s x= units units units units Vo= Vo Vo Vo units units units units for a ball thrown straight up...
-
What is the density of fresh water if 4.4 cm has a mass g/cm of 4.4 g?
-
Medical technology can outfit a patient with an artificial heart, or cure vision defects with the touch of a laser. However, hospitals still struggle with their back-office processes, such as getting...
-
In Problems 1522, find the principal needed now to get each amount; that is, find the present value. To get $750 after 2 years at 2.5% compounded quarterly.
-
Can two hosts in two different networks have the same link-layer address? Explain.
-
Explain why we do not need the router in Figure 9.15.
-
Is the size of the ARP packet fixed? Explain.
-
Certain organizational structures may work well in some situations and yet be completely ineffective under a different set of circumstances. Consider the following very different organizational...
-
Case: Project Portfolio Management at XYZ Pharma that was developed at London School of Economics. The case describes the R&D project selection and prioritization problem at a major pharmaceutical...
-
Nike did not respond convincingly to Jeff Ballinger's criticism, which caused a continuing question and loss in the future years. They avoided answering questions about wages. Their further actions...
Study smarter with the SolutionInn App