0% found this document useful (0 votes)
11 views

Assignment 2

Uploaded by

Ahmad arja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Assignment 2

Uploaded by

Ahmad arja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Fall 2024 - SWER348

Assignment 2

Data Analytics with Java Streams

Project Overview

Create a data analytics application that processes a collection of records from a dataset (e.g., sales data, student grades,
or any other dataset). You should use Java Streams to perform the various operations, do not use any loop structure. The
project is structured into two steps:

Step 1: Work on Sales Data

Download the file sales.csv from eclass and implement the following using this dataset.

Data Processing:

• Implement methods to read data from the dataset into a collection (e.g., List<Sale>).

• Use Streams to perform the following operations:

o Filter records based on specific criteria (e.g., products sold over a certain quantity).

o Sort records based on price or quantity.

o Map records to different representations (e.g., calculate total sales for each product).

o Use IntStream, LongStream, and DoubleStream to perform statistical analyses (e.g., average sales).

Aggregation:

• Use the reduce method to calculate total sales or total quantity sold.

• Collect the processed data into a mutable collection (e.g., Map<String, Double> for total sales by product).

• Group the data by specific criteria (e.g., by product name) and apply aggregate methods (e.g., counting the
number of sales per product).

Unit Testing:

• Write unit tests for each stream operation using JUnit. Name your file SalesTest.java.

o Filter Test: Ensure products are correctly filtered based on a condition (e.g., quantity greater than 5).

o Sort Test: Test if products are sorted properly by price or sale date.

o Map Test: Validate transformations (e.g., converting sale records to total sale amounts).

o Aggregate Methods Test: Verify correct results for sum, average, min, max, and count.

o Reduce Test: Ensure correct reduction of data (e.g., total sales).

o Collect Test: Test if the elements are correctly collected into mutable collections.

Step 2: Make your project Generic

Now refactor your code so that it works on any dataset. Implement generic methods that work on multiple types of data,
such as sales records and student grades. Generalizing your code helps to improve flexibility and reusability.

Download the file students.csv from eclass and write unit tests that validate the correctness of stream operations for
both sales and student grades. Name your file StudentsTest.java.
GitHub Instructions:

• Branching: You should implement each task in a branch, each student is responsible for a task. Delete your
branches after finishing each task. But keep the branch after finishing step 1. Your final work will be on the main
branch.

Accept the GitHub Classroom Assignment. It is a group assignment, if your team mate created the group before you,
simply join it, otherwise, create it yourself.

You might also like