Question: 8 . Refer to the below example of Inner Class, create, compile and run a Java program that calculates the average, minimum and maximum age

8. Refer to the below example of Inner Class, create, compile and run a Java program that calculates the average, minimum and maximum age of your friends and family members.
Take screen capture of the program output and code. The program should include nested class/inner class, appropriate variables, types and methods. // Use an inner class.
class Outer
{
int nums[];
Outer(int n[])
{
nums = n;
}
void analyze()
{
Inner inOb = new Inner();
System.out.println("Minimum: + inOb.min());
System.out.println("Maximum: + inOb.max());
System.out.println("Average: + inOb.avg());
}
// This is an inner class.
class Inner
{
int min()
{
int m = nums[0];
for(int i =1; i < nums.length; i++)
if(nums[i[< m) m = nums[i];
return m;
}
int max()
{
int m = nums[0];
for(int i =1; i < nums.length; i++)
if(nums[i[> m) m = nums[i];
return m;
}
int avg()
{
int a =0;
for(int i =0; i < nums.length; i++)
if(nums[i[< m) m = nums[i];
return a / nums.length;
}
}
}

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!