ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 02 May 2017 My Price 8.00

public class Arrays

I am having trouble calling a private method within the same class.

It is part of the requirements for full-credit. The code i have so far is:

 

public class Arrays    {

    private int[] array;

    private int count;

 

    public Arrays(int size)    {

        array = new int[size];

        count = size;

 

        Random rand = new Random();

        for(int i = 0; i < count; i++)    {

            array[i] = (rand.nextInt(10));

        }

    private int calcSum()    {

        int sum = 0;

        for(int i = 0; i < count; i++)    {

            sum = sum + array[i];

        }

 

// calcAverage (this is where i am having the trouble)

//Use the calcSum() private method in your computation of the average for full credit.

//Hints:
//• You will need to make use of the total elements in the array.
//• You will need to cast the result to a double at the appropriate time to achieve an accurate average.
   

public double calcAverage()        {

 

    }

There is a driver program to test this class that i haven't written yet but I will. What i really need help with is the "How" and the "syntax" to do this properly.

 

Thank you for any help.

Answers

(11)
Status NEW Posted 02 May 2017 06:05 AM My Price 8.00

-----------

Not Rated(0)