Design and implement an application called Meanjava that com
Design and implement an application called Mean.java that computes and prints the mean of two lists of integers coming from the same list that has n numbers: x0, x1, …, xn-1. The first list L1 contains x0, x2, …, through xn-1 if n is odd or through xn-2 if n is even. The second list L2 contains x1, x3, …, through xn-1 if n is even or through xn-2 if n is odd. Ask the user to input n and read the value of n. Then ask the user to input n integers and save them in an array. Print out L1 and compute the mean as a floating point value for L1. Then print out L2 and compute the mean as a floating point value for L2, using the following formula:
Solution
import java.util.Scanner;
/**
*
* @author Ankita
*/
public class Mean{
public static void main(String args[]) {
public void computemean()
{
Scanner input = new Scanner(System.in);
System.out.println(\"number of even number array 1 : \");
//get number
int n = input.nextInt();
//create array with size n
int[] array = new int[n];
//initialize the initial value of sum
int sum = 0;
//get the input numbers using for loop
for (int m = 0; m < n; m++) {
System.out.print(\"Array element \" + m + \" : \");
array[m] = input.nextInt();
}
Scanner input1 = new Scanner(System.in);
System.out.println(\"number of odd numbers in array 2 : \");
//get number
int n1 = input.nextInt();
//create array with size n
int[] array1 = new int[n];
//initialize the initial value of sum
int sum1 = 0;
//get the input numbers using for loop
for (int m1 = 0; m1 < n1; m1++) {
System.out.print(\"Array element \" + m1 + \" : \");
array1[m1] = input.nextInt();
}
//calculate sum of all array elements
for (int m = 0; m < n; m++) {
sum = array[m] + sum;
}
System.out.println(\"Total value of array element1 = \" + sum);
double meanreq;
//calculate average value
meanreq = sum / array.length;
System.out.println(\"Average of Array 1 = \" + meanreq);
//calculate sum of all array elements
for (int m1 = 0; m1 < n1; m1++) {
sum1 = array[m1] + sum1;
}
System.out.println(\"Total value of array element 2 = \" + sum1);
double meanreq1;
//calculate average value
meanreq1 = sum1 / array1.length;
System.out.println(\"Average of Array 2 = \" + meanreq1);
}
}
}

