Question: Code an interface called CanCalculate. Your interface must contain the following method signature int factorial ( int n ) ; Code a class Calculator that
Code an interface called CanCalculate. Your interface must contain the following method signature
int factorialint n;
Code a class Calculator that implements the interface. It must use iteration to compute factorialn
Code a tester class for class IterativeCalculator, call it IterativeTester. The tester must declare a variable of type CanCalculate and assign it a reference to an object of type IterativeCalculator, and then enter a loop that computes the factorials of the integers ranging between and
CanCalculate myCalc new IterativeCalculator;
for int i ; i ; i myCalc.factoriali;
Code a class RecursiveCalculator that implements interface CanCaculate. It must use recursion to compute factorialn
Code another tester class, call it RecursiveTester. It must declare a variable of type CanCalculate and assign it a reference to an object of type RecursiveCalculator, and then enter a loop that computes the factorials of the integers ranging between and
CanCalculate myCalc new RecursiveCalculator;
for int i ; i ; i myCalc.factoriali;
Rubric
points Interface CanCalculate:
Has the required method signature.
points IterativeCalculator class
Implements interface CanCalculate.
Has the required, correct concrete iterative implementation of factorial
points RecursiveCalculator class
Implements interface CanCalculate.
Has the required, correct concrete recursive implementation of factorial
points IterativeTester class
Has the requires variable declaration, object instantiation and for loop.
points RecursiveTester class
Has the required variable declaration, object instantiation and for loop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
