Computer Science, asked by mnzmansuri, 23 hours ago


Add the elements in a Number[] and return the Number result. If values contains any null values, then return null,
Test1.java
package testi;

public class Test1

// DO NOT write a main method
public static Double addValues (Double() values) {

}

Answers

Answered by Anonymous
15

The program to add the elements and return the result is below:

Test1.java

package testi;           //package here is import.java.util.*;

public class Test1

{

public static Double addValues(double Number[])

{

Scanner sc = new Scanner(System.in);

int i,sum=0;

System.out.println("Enter the values in the array");

for(i=1; i<=Number.length; i++)

{

Number[i] = sc.nextInt();

}

if(Number[]==NULL)

return null;

else

for(i=1; i<=Number.length; i++)

{

sum = sum + Number[i];

}

return sum;

}

}

The command "Number.length" is the function that finds out the length of the array.

Answered by balanjaneyulu100
0

Answer:

Add the elements in a Number[] and return the Number result. If values contains any null values, then return null,

Test1.java

Similar questions