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 7
public void setElements() method to store 5 elements in array number
public void printElements() method to print elements of array
public void calculateSum() method to calculate sum of 5 elements and store
it at 6th location of the array number and at 7th
location store total number of elements i.e 5
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 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 Programming Questions!