Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA ILLUMINATED An Active Learning Approach 3 rd Edition. CHAPTER 8 8.10.6 50. Write a value-returning method that returns the product of all the elements

JAVA ILLUMINATED

An Active Learning Approach 3rd Edition.

CHAPTER 8

8.10.6

50. Write a value-returning method that returns the product of all the elements in an integer array.

public class ArrayProduct { public static void main( String [] args ) { int [] intArray = { 1, 2, 3, 4, 5, 6 }; System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[i] + " " ); System.out.println( ); System.out.println( "The product of all elements in the array is " + arrayProduct( intArray ) ); } // Insert your code below

51. Write a void method that sets to 0 all the elements of an integer array.

public class ZeroArrayElements { public static void main( String [] args ) { int [] intArray = { 1, 2, 3, 4, 5, 6 }; System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[i] + " " ); System.out.println( ); System.out.println( "Calling zeroArray method" ); zeroArray( intArray ); System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[i] + " " ); System.out.println( ); } // Insert your code below }

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 Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

3. Are there intergroup tensions, frictions, or misunderstandings?

Answered: 1 week ago