# Methods with arrays in java

###### Question:

I have to write a method that will output the following:Please enter 10numbers: 5 3 2 8 14 22 5 3 20 3
Sum of numbers is:85
New array contents is: 86 5 11 17 25 8 6 23 6the method must add all integers in array and also display thearray with each element incremented by the last elementamount.My program is not summing the array properly and also notputting spaces while displaying new array.Here is what Ihave so far.import java.util.*;
public class Spring2004Tues
{
public static void main(String[] args) {
Scanner keyboard = newScanner(System.in);
// declare the array ofintegers
int[] theArray = newint[10];
int i;//loop counter
int sum = 0; // willstore sum of array values
System.out.println("Name: Christopher Kaplan, final exam problem 1,CS 107");
for (i=0; i<10; i++){
// write the statement using cin to read in each number into arrayelement i
theArray[i] = keyboard.nextInt();
}
sum(theArray);// Call the function to getthe sum
// Function should also increment array values
System.out.println("Sum of numbers is: " + sum(theArray));
System.out.print("New array contents is: ");//+Arrays.toString(theArray));
for (i=0; i<10; i++) {
// display the contents of the array
System.out.print(theArray[i]);
}
}
public static int sum(int[] array){
int sum = 0;
for (int i=0;i<array.length;i++){
array[i] = array[i] + array[array.length -1];
sum = sum + array[i];
}
return sum;
}
}
I will rateASAP if someone can help me resolve this issue.

#### Similar Solved Questions

##### Explain the Typical medical treatment for Malabsorption syndrome. Provide a thorough response, a few paragraphs citing...
Explain the Typical medical treatment for Malabsorption syndrome. Provide a thorough response, a few paragraphs citing examples of treatment and what the treatment modalities do...
##### Question 9 (1 point) Find the value of x. Round the lengths of segments to the...
Question 9 (1 point) Find the value of x. Round the lengths of segments to the nearest tenth and the measure of angles to the nearest degree. 12.5 a) 40 b) 56 c) 34 d) 55 15...
##### I have a couple questions that I'm looking for help explaining as my textbook doesn't go...
I have a couple questions that I'm looking for help explaining as my textbook doesn't go into great detail on either subjects. Thanks! 1.) What was the “Great Inflation." What are the basic causes and types of inflation that existed? 2.) According to The Gordon Growth Model, what a...
##### What parts of the digestive system are involved with mechanical digestion?
What parts of the digestive system are involved with mechanical digestion?...
##### How is the area of a wall calculated?
How is the area of a wall calculated?...
##### Find the standard deviation, s, of sample data summarized in the frequency distribution table given below...
Find the standard deviation, s, of sample data summarized in the frequency distribution table given below by using the formula below, where x represents the class midpoint, f represents the class frequency, and n represents the total number of sample values. Also, compare the computed standard devia...