210k views
2 votes
Functional Interfaces and Lambda Expressions

Using IntCalculator.java from chapter 10 (page 684) of the Gaddis text, implement both an Anonymous Inner Class, and a Lambda Expression that returns the results of the following expressions:
// 1. given int parameter x, return the value of the polynomial
return x2 + 2x + 4;
// 2. given two double parameters x and y, return x to the y
return xy; // use Math.pow
// 3. given a double parameter, r, return ?*r2
return Math.PI * r * r;
// 4. given int parameter x, return x!, if x<= 0, just return 1
Notice that there should be both an anonymous inner class implementation, AND a lambda expression implementation for each of the 4 expressions. Include a separate class that has a public static main method that tests your four expression handlers. Place all of your java files into a single zip file and upload to Canvas.

User Andban
by
5.3k points

1 Answer

2 votes

Answer: the asnwer to this is poopyscoop

Step-by-step explanation:

User Nick Spicer
by
4.5k points