Question
Write one program that includes the following methods. I give you these method headers. You need to write the methods and also invoke them from
Write one program that includes the following methods. I give you these method headers. You need to write the methods and also invoke them from your main method.
a)public static void printArray( int [] arr1) Method receives an array of integers and prints them out on one line separated by a space
b) public static int[] newArrayreversed( int [] arr1) Method receives an array and RETURNS a REVERSE copy of that array
c) public static char initial(String s) Method receives a String and returns the first character of the String
d) public static int sumEvens( int [] Method receives an integer array and return the sum of just the even values in the array
arr1)
e) public static int sumOddIndexArray( int [] arr1) Method receives an integer array returns the sum of values at the odd index locations( example sum of arr1[1], arr1[3], arr1[5]...)
Sample output for Part 3:
The array I am using is 0 1 2 3 4 5 6 7 8 9 10
Array that is returned from reverse 10 9 8 7 6 5 4 3 2 1 0
The initial of Mary is M The sum of the even values in array is 30 The sum of the values in odd indexes is 25 ----jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started