Question: GenIFTester ( 3 0 ) Create two files for this exercise, one for the functional interface GenericInterface and one to test it called GenIFTester. GenericInterface

GenIFTester (30)
Create two files for this exercise, one for the functional interface GenericInterface and one to test it called GenIFTester.
GenericInterface
This is a generic class of type T.
It has one abstract method called func that has a parameter of type T and returns a value of type T.
GenIFTester
This program can all be done in main
Create a Scanner to read from the keyboard.
Create a lambda function called reverse that implements GenericInterface This lambda accepts a variable of type String and reverses all the characters of the parameter. It returns the reversed String.
Then do three times
Request an input String.
Use reverse to reverse the String and print out the original String and the reversed String (see Sample IO below).
Create a lambda function called factorial that implements GenericInterface This lambda accepts a variable of type int and calculates its factorial value. It returns the int value. (Note: Autoboxing will take place automatically or you can use Integer in place of int if you like
Then do three times
Request an input integer.
Use factorial to calculate the factorial value and print out the original number and factorial (see Sample IO below).
Sample Input/Output
Enter a string to be reversed:
abcde
The entry abcde reversed is edcba
4
Enter a string to be reversed:
My Day Is Great 100%
The entry My Day Is Great 100% reversed is %001 taerG sI yaD yM
Enter a string to be reversed:
39-87-Grand
The entry 39-87-Grand reversed is dnarG-78-93
Enter an integer to be factorialised:
4
factorial of 4=24
Enter an integer to be factorialised:
6
factorial of 6=720
Enter an integer to be factorialised:
9
factorial of 9=362,880

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!