Define a Java interface named NumTrackerInterface. A class that implements this interface must keep track of both the sum and count of numbers submitted to it through its add method, and provide getters for the sum, count and average of those numbers. The add method should accept an argument of type int, the getSum and getcount methods should both return values of type int, and the getAverage method should return a value of type double. Create a class called Tracker1 that implements the NumTrackerInterface. This class should use three instance variables: count, sum, and average. Create a class called Tracker2 that implements NumTrackerInterface. This class should use two instance variables: count and sum. To ensure the code works, make sure the print the numbers, sums, counts, and averages to the screen. Subject: Java Programming
Define a Java interface named NumTrackerInterface. A class that implements this interface must keep track of both the sum and count of numbers submitted to it through its add method, and provide getters for the sum, count and average of those numbers.
The add method should accept an argument of type int, the getSum and getcount methods should both return values of type int, and the getAverage method should return a value of type double.
Create a class called Tracker1 that implements the NumTrackerInterface. This class should use three instance variables: count, sum, and average.
Create a class called Tracker2 that implements NumTrackerInterface. This class should use two instance variables: count and sum. To ensure the code works, make sure the print the numbers, sums, counts, and averages to the screen.
Subject: Java
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images