Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Data
- {
- public static double average(Measurable[] objects)
- {
- double total = 0;
- for (Measurable obj : objects)
- {
- total = total + obj.getMeasure();
- }
- if (objects.length > 0)
- {
- return total / objects.length;
- }
- else
- {
- return 0;
- }
- }
- public static Measurable max(Measurable[] objects)
- {
- double max = objects[0].getMeasure();
- int maxIndex = 0;
- for (int i = 0; i < objects.length; i++)
- {
- if (objects[i].getMeasure() > max)
- {
- max = objects[i].getMeasure();
- maxIndex = i;
- }
- }
- return objects[maxIndex];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement