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

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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