Write a Java program that reads a 1D array of integers from standard input and returns it.
//TestCode.java import java.util.Scanner; public class TestCode { public static int[] readArray(){ int size; Scanner scan = new Scanner(System.in); System.out.print("Enter size of array: "); size = scan.nextInt(); int arr[] = new int[size]; System.out.println("Enter "+size+" values for array"); for(int i = 0;i<size;i++){ arr[i] = scan.nextInt(); } return arr; } public static void main(String[] args) { int arr[] = readArray(); System.out.println("\nArray is:"); for(int i = 0;i<arr.length;i++){ System.out.print(arr[i]+" "); } System.out.println(); } }
Write a Java program that reads a 1D array of integers from standard input and returns...
Write a program that reads a sequence of integers into an array and that computes the alternating sum of all elements in the array. For example, if the program is executed with the input data: 2 1 4 9 16 9 7 4 9 11 Then it computes 2 - 1 + 4 - 9 + 16 - 9 + 7 - 4 + 9 – 11 = 4 Use a scanner object to gather the inputs from the user....
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
In Java Write a program that reads an arbitrary number of 25 integers that are positive and even. The program will ask the user to re-enter an integer if the user inputs a number that is odd or negative or zero. The inputted integers must then be stored in a two dimensional array of size 5 x 5. Please create 3 methods: 1. Write a method public static int sum2DArray( int [1] inputArray ) The method sums up all elements...
In Java* Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
Write a program that reads k integers and displays their sum. Write a program that reads k values representing family income from the keyboard and place them into the array. Find the maximum income among these values. Count the families that make less than 10 percent of the maximum income. (JAVA)
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.
Write a Java program that reads four integers and prints "two pairs" if the input consists of two matching pairs (in some order) and "not two pairs" otherwise. For example, 1 2 2 1 two pairs 1 2 2 3 not two pairs 2 2 2 2 two pairs
Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order (from smallest to largest). You can either get the array as input or hardcode it inside your program.
Write a Java program that reads 10 integers from the keyboard and outputs all the pairs whose sum is 30 .
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.