004-001-011

Passing Arrays to Methods

Hard

Problem Description

Passing Arrays to Methods

Learning Objective: Understand how to pass arrays as method arguments and return arrays from methods

Overview

Create methods that process arrays and practice array passing.

Specifications

  • double average(int[] arr): calculates and returns array average
  • int[] doubleValues(int[] arr): returns new array with each element doubled
  • Test with array {10, 20, 30}

Output Format

Original: 10 20 30
Average: 20.0
Doubled: 20 40 60

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?