What is wrong with the stream pipeline

Assignment Help Other Subject
Reference no: EM133139597

COIT20256 Data Structures and Algorithms - Central Queensland University

Question 1: Assuming that random is a SecureRandom object, explain in detail the stream pipeline:

random.ints(1000000, 1, 3)
.boxed()
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
.forEach((side, frequency) ->
System.out.printf("%-6d%d%n", side, frequency));

Question 2: Reimplement the following statement using a lambda as the event handler:

1. slider.valueProperty().addListener(
2. new ChangeListener<Number>() {
3. @Override
4. public void changed(ObservableValue<? extends Number> ov,
5. Number oldValue, Number newValue) {
6. System.out.printf("The slider's new value is %s%n", newValue);
7. }
8. }
9. );

Activity One
Implement the program designed as part of Activity One in Lecture. The question is repeated here.

Question 3. Write a java program to generate twenty five random integers between 0 and 100 (inclusive), display the values, display the sorted values, sum and average of the values. Display the list of values greater than 50. Use Lambdas.

Activity Two

Question 4. Write a stream operation to calculate and display the average employee salary by department. (Use the source code in Fig.17.20 from the Example source files used in lecture, available at the Unit Website, Week 8 Folder.

Question 5. What is wrong with the following stream pipeline?
1 list.stream()
2 filter(value -> value % 2 != 0)
3 sum()
Write the correct stream pipeline.

Question 6. Write a java program to:
a) Display the original string values in the array
b) Display the string values converted to uppercase
c) Display the string values in ascending order after filtering the values starting with g or less
d) Display the string values in descending order after filtering the values starting with g or less.
Data: String [] names = {"bob", "Mary" "Andrew", "Tomy", "Michael", "Kathy", "lily", "Frances"}

Question 7. Use the class Invoice provided at the unit website in Week 8 folder. Use the sample data shown below. Perform the following queries on the array of Invoice Objects and display the results:
a) Use lambdas and streams to sort the Invoice objects by Price, then display the results.
b) Use lambdas and streams to map each Invoice to its PartDescription and Qunatity, sort the results by Quantity, and display the results.
c) Use lambdas and streams to map each Invoice to its PartDescription and the value of the Invoice (i.e., Quantity * Price). Order the results by Invoice value.
d) Modify Part (d) to select the Invoice values in the range $200 to $500. (Reference: Textbook Chapter 17,Exercise 17.11)

Table 1: Sample Data for Question 3

Part Number

Part Description

Quantity

Price

83

Electric Sander

7

57.98

24

Power Saw

18

99.99

7

Sledge Hammer

11

21.50

77

Hammer

76

11.99

39

Lawn Mower

3

79.50

68

Screwdriver

106

6.99

56

Jig saw

21

11.00

3

Wrench

34

7.50

Attachment:- datastructure.rar

Reference no: EM133139597

Questions Cloud

What are the benefits of guest history databases : Can you answer these 3 questions with a minimum of 100 words for EACH question?
What is the employer responsibility : What is the employer's responsibility when an incident of sexual or racial harassment is reported to a supervisor?
Are regional trade blocs good for global trade or not : Some groups of nations are forming trade blocs, like North America or Europe. Are regional trade blocs good for global trade or not? Do bilateral trade agreemen
Case study-uaw to caw to unifor : As shown by the discussion of the 1940s Rand Formula decision, the UAW had a long history in Canada. For much of that period, the Canadian union members simply
What is wrong with the stream pipeline : Write a java program to generate twenty five random integers between 0 and 100 (inclusive), display the values, display the sorted values
Affirmative action in employment : For this assignment, you will explore the many facets associated with AAPs. Review the video "Affirmative Action in Employment."
What are the firm ROE and ROIC : The firm finances with only debt and common equity, so it has no preferred stock. What are the firm's ROE and ROIC
How is the walmart company structured globally : How is the Walmart company structured globally? Explain why it is structured this way?
Determine employee engagement : Design a survey to determine employee engagement.

Reviews

Write a Review

Other Subject Questions & Answers

  Illustration of self-improvement

One of the over-arching themes in Franklin's Autobiography is that of self-improvement. Franklin intends for his own experience to serve as a model for others. Discuss key ways that Franklin presents his story as an illustration of self-improvement.

  Contrast social mobility in developing and industrialized

Contrast social mobility in developing and industrialized nations. Do you think the differences will eventually disappear? Why or why not?

  Strategic plan to grow the business or organization

Conduct a quick SWOT analysis to determine areas that offer opportunities for change.

  Where is robotics on the hype cycle

Where is robotics on the hype cycle? How does its placement affect other pieces within the hype cycle? Provide an example that supports your ideas.

  Which approach to dealing with criminals is best

Which approach to dealing with criminals and their victims is best - retributive justice or restorative justice? Why? Give examples to support your conclusion.

  Describe your chosen pharmacological treatment

What laboratory tests should you order, and what is your primary diagnosis at this point and subsequent steps in his treatment

  Create a layout for a post-event meeting

Create a layout for a post-event meeting highlighting which elements could be improved and which could be omitted from the next edition

  Able to negotiate a price

You are able to negotiate a price for a 2014 Ford Fusion Hybrid including tax, title and registration for $20,000. The dealer is willing to lease the car at $220 per month for 60 months ($3,000 due at signing)

  Describe historic sites and landmarks

Brief summary of the setting, with highlights of important places, Historic sites and landmarks

  Sociology matters assignment

Sociology Matters Assignment help and solutions:-Can you think of a way to reduce one or more of those privileges so that others can be more equal

  HADVC 210 - History of Photography Assignment

HADVC 210 - History of Photography Assignment help and Solution - University of Alberta, Canada - Assessment Writing Service

  What are the group purpose mission and goals

What are the group purpose, mission, and goals? The group joined together to discuss their monthly goals. Once the facilitator opened up the room with a "good morning all, please help yourself to the treats" everyone began to indulge. She then whe..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd