Question: Create a class ArrayNumber to have following members: private int number [ ] array of size 7 public void setElements ( ) method to store
Create a class ArrayNumber to have following members:
private int number array of size
public void setElements method to store elements in array number
public void printElements method to print elements of array
public void calculateSum method to calculate sum of elements and store
it at th location of the array number and at th
location store total number of elements ie
public int printAverage int totalSum, int totalNumber method to calculate
and print average of numbers.
Create a class TestArrayAverage having main method. Create an object of
ArrayNumber class. Call setElements printElements to set and print
elements of array. Call calculateSum to calculate sum of elements in an
array. Call printAverage to calculate and print average by passing total sum
and total number of elements in an array.
Observe the exceptions occurring when wrong index numbers are passed and
value of total number as zero.
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
