Question: please answer all the question in Java, thx Questions 1. Arrays are easy to use in av. An army wantle mat he declared, and the
Questions 1. Arrays are easy to use in av. An army wantle mat he declared, and the array itself mast be allocated via the keyword new. For example, the line below creates an arty named "x with enough space for 13 integet Satu ** new int (13) Write a program which asis the user how many values they would like to process, then creates an array of the specified length, and reads the specified number of values and stores them in the array you created. You may assume all values are integers 2. Arrays can be used to methods as arguments parameters just like other types of data. In your program's main class, define a static method named printArray that takes an array of integets as its only argument and prints the elements of the array You should print all the elements of the array on one line, separated by spaces, with no extra space after the last element Hint 1. You may want to use the length property of the array to know how many clements to print. Hint 2 pour method bould look something like this public static void printArrayCant ) ) { // code to print array goes here ) Lab contend 3. Write another static method named array Mean which takes an array as a parte and returns a floating point value which is the mean value (le, the average of the arrny elements. If A - 1. 2. 3) then arrayMean(A) should return (1+2+3)/3- 2.0. Modify your main method to print the man of the input from the first 4. A Java wray is a great way to represent a vector from regular math. Write another static method and do Prod which takes two arrasas parameters and returns the sector dat product, which is obtained by multiplying each element and computing the sum according to the expression Ann Where is the number of elemente in each of the arrays. Note that this method only malossif A and B have the same number of elements, and note that this method bould not modify either stay As a test, if A- (1. 2. 3) and B = {4. 5. 6) then dot Prod(A.B) should retum Modify your main method to print the dot product of the we's input array with itsell. Note that this value should never be septive. An example session with the complete program might look like this: How many numbers to procesa? > 4 > 3214 You entered: 3 2 1 4 Meant 2.5 Sell Dot Product: 27 Note: the user input is indicated by beginning the line with
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
