Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here are some JAVA Problems - - For each of the following exercises provide a solution that uses methods of the Stream interface. 1 Write
Here are some JAVA Problems
For each of the following exercises provide a solution that uses methods of
the Stream interface.
Write a method getElement implementing a partial function that given an
array arr and an int index returns arrindex if defined. Use Optional as the result
type. Next write methods implementing the following partial functions:
sqrt that applied to an integer returns its square root as a double, if the
argument is not negative;
half, that applied to an integer returns its half as an integer, if the argument is
even.
Finally write a method that composing getElement, sqrt and half, when applied to an
array of integers arr and to an int index, returns the square root of the half
of arrindex if defined.
Consider the attached csv file people.csv This file stores information about people
subscribed to a simple service. Each line of the file represents a record. The fields of
each record are separated by a comma and have the following meaning
idfirstname,surname,title,address,town,country,postcode,subscription
paid,gender,date of birth
In a record the fields id firstname, surname, date of birth, subscription paid are
mandatory, while the others are optional denoted by in the file Implement a
class Subscriber representing a subscriber, providing a property for each field. Use
the Optional class to denote optional fields.
Write a static method loadDatabase that returns a List containing the
records of the file subscriber.csv Furthermore, implement another static
method PaymentFromGB that given a List prints the subscribers from GB
that have paid the annual fee.
Hint: Use the methods of Optional class to deal with optional values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started