Write a Java program that takes an int array as input, and returns the average of all the values in the array. No class construction is necessary; however, the complete signature and definition and brief documents are needed.
public class Average5 { public static double getAverage(int arr[]){ double s = 0; for(int i = 0;i<arr.length;i++){ s += arr[i]; } return s/arr.length; } public static void main(String args[]){ int arr[] = {3,2,4,1,5}; System.out.println("Average = "+(getAverage(arr))); } }
Write a Java program that takes an int array as input, and returns the average of...
a. Write a function arrayToMap that takes an array of strings and returns a std::map<int, string> such that the values in the map are the string values in the array of strings, and the keys in the map are the corresponding array indices of the string values. You may assume all necessary libraries have been included in your program and your solution must be syntactically correct in order to receive full credit. map<int, string> arrayToMap(string arr[], int arrSize) { b....
1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...
(Java) - Write a recursive program that takes array of number and an integer, and returns true if the integer is in the array or false if the integer is not in the array
Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X – Y The signature of the function is: int f(int[ ] a) Examples if input array is return {1} 1 {1, 2} -1 {1,...
11) Write a method (including header and body) that takes as an input an array of doubles and f three doubles containing the average, the maximum and the minimunm values of the input array. Test the program by calling the method from the main method. For example Input: 1 2 3 45 Output: 3 5 1 12) Write a Java method that takes a string as an argument and returns the reverse the string. Test the program by calling the...
Write a Java program that reads a 1D array of integers from standard input and returns it.
JAVA Array 3. Write a method called noVowels that takes a String as input and returns true if it doesn't contain any vowels (a, e, i, o, u)
X43: countEvens Write a function in Java that takes an int array as its parameter and returns the number of even ints it contains. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1. Complete the code bellow. Complete the code below. Use: logic conditionals if arrays loops mod public int countEvens(int[] nums) { }
java code Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.
Write program in JAVA with a method that returns an array. The method should accept as input a comma-delimited string with three values from a user. The array should store each value in a different element. Use Try..Catch error handling and print any failure messages, or print success from within method if execution is successful (see Chapter 13 in the text). Call the method from the main method of the program to demonstrate its functionality by looping through the array...