The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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.