Question
I am getting these errors for getcountgroupbymedia Cannot infer type argument(s) for flatMap(Function super T,? extends Stream extends R>>) gettotalfeesgroupbymedia has errors too and gettotalitemsgroupbymedia
I am getting these errors for getcountgroupbymedia Cannot infer type argument(s) for
gettotalfeesgroupbymedia has errors too and gettotalitemsgroupbymedia kindly could you solve it and replace it with the correct code
package adminSite;
import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors;
import yourPrime.*;
public class FuncUtil { private Map
Comparator
userDb.values().stream() .sorted(comparator) .map(details) .forEach(System.out::println); }
// TODO create a method to return the average outstanding fees from all accounts using Java 8 stream and lambda expression. // public double getAverageOutstanding() { return userDb.values().stream() .mapToDouble(Subscriber::getFees) .average() .orElse(0); } // TODO create a method to return the outstanding fees from all accounts group by the media type. // You should make use of Java 8 Streams and lambda expression to do this - return map // public Map
// Loop through each media type for (MyMedia.Media media : MyMedia.Media.values()) {
// Compute the total fees for the current media type Double fees = userDb.values().stream() .flatMap((Subscriber subscriber) -> subscriber.getMedia().get(media).stream()) .mapToDouble(MyMedia::getFees) .sum();
// Store the total fees for the current media type in the Map totalFees.put(media.toString(), fees); }
// Return the Map of total fees for each media type return totalFees; } public Map
public Map
// TODO create a method to return the total number of items from all accounts using Java 8 streams and lambda expression. // group by the media type. Use the programming logic (idioms) that you've implemented in the getTotalFeesGroupByMedia() // method as a source of inspiration in completing this method. // }
@override // create subscribers for testing purpose Map Song mapLibSong = new HashMap \langle angle() ; mapLibsong.put( , Arrays. asList(s3, s2, s4)); maplibsong.put(1, Arrays. asList(s1,s2,s3, s4)); mapLibsong.put(2, Arrays.asList(s2,s3, s4, s5)); maplibsong.put(3, Arrays. asList(s3, s5)); maplibsong.put(4, Arrays. asList(s1, s2, s4)); mapLibMovie.put( , Arrays. asList (m3,m2,m4)); mapLibMovie.put(1, Arrays. asList(m1, m2, m3, m4)); maplibMovie.put(2, Arrays. asList (m2, m3)); mapLibMovie.put (3, Arrays. asList (m3, m5)); mapLibMovie.put(4, Arrays. asList(m1, m2, m4)); Map Book mapLibBook = new HashMap \langle angle() ; mapLibBook.put( , Arrays. asList(b3, b2, b4)); mapLibBook.put(1, Arrays.asList(b1, b2, b3, b4)); mapLibBook.put (2, Arrays. asList(b2, b4, b5)); mapLibBook.put (3, Arrays.asList(b3, b5)); mapLibBook.put(4, Arrays. asList(b1, b2, b4)); List listUser = Arrays. asList("Arthur Shelby", "Tommy Shelby", "Ada Shelby", "John Shelby", "Finn Shelby"); List listId = Arrays. asList(" 001 ", "002", "003", " 004 ", "005"); Map userDb = new HashMap \langle angle() ; MyMedia myMedia; for (int i=0;iStep 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