Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ADD SOURCE CODE TO THE FOLLOWING PROGRAM TO EXPLAIN CODE: import java.util.Arrays; public class RecursiveAverage { public static void main(String[] args) { double arr[]= new

ADD SOURCE CODE TO THE FOLLOWING PROGRAM TO EXPLAIN CODE:

import java.util.Arrays;

public class RecursiveAverage {

public static void main(String[] args) { double arr[]= new double[10]; fillArray(arr, arr.length); System.out.println("Array double values: "); System.out.println(Arrays.toString(arr)); System.out.println("Average is "+getAverage(arr)); } public static void fillArray(double arr[], int size){ if(size == 0){ return; } else{ arr[size-1] = Math.random(); fillArray(arr,size-1); } } public static double getSum(double arr[], int size) { if(size == 0){ return 0; } else{ return arr[size-1] + getSum(arr, size-1); } } public static double getAverage(double arr[]) { return getSum(arr, arr.length)/arr.length; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago