Question: Using Java please help me design Write an interface called Calculatable that has a method called calculate that accepts an integer as a parameter and

Using Java please help me design

Write an interface called Calculatable that has a method called calculate that accepts an integer as a parameter and returns a double based on some calculations that are done with data members and the integer parameter. public interface Calculatable {double calculate (int i);} Define at least two classes that implement Calculatable and have different calculate methods. Create objects an call calculate on each one. Print out the output of these method calls. Create an array of Calculatable objects in main and call the sumCalculate method with the array and an integer of your choice. You can define the array as follows Calculatable [] calcob; Make a method called su accepts that an array of Calculatable objects and an integer parameter x. It should return the sum of the values that are returned by each object's call to its calculate method with the same parameter x. Realize that even though it's not possible to make instances of an interface (like Calculatable), it is possible to have a reference of type Calculatable and then assign an object to the reference. Of course, the object must be of a type that implements the Calculatable interface. Exercise (not graded) Make your Item class implement Comparable and then have the ShoppingCart keep the items in sorted order using the Arrays.sort method

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 Databases Questions!