# 1 create a 1 dimensional array with n elements get the size of the array as user inp 5346469

1. Create a 1-dimensional array with n elements; get the size of the array as user input (validate!), max size should be 10 (declared as class constant). Your program should use modularity. Have methods to:

Take input from the user the elements of a 1-dimensional array.

Print a 1-dimensional array. Compute the average value/1-dimensional array.

Display the difference between each value/1-dimensional array and the average.

Display all elements with odd subscripts.

Display all elements with even subscripts.

Compute the sum of all elements with odd subscripts.

Compute the sum of all elements with even subscripts.

Generate output similar to the sample output below.

SAMPLE RUN:

Do you want to start(Y/N): y

Enter array size: 7

Now enter 7 values: 56.7 78.9 23.5 111.5 114.7 99.99 88.88

The array elements are: 56.70 78.90 23.50 111.50 114.70 99.99 88.88

The average value = 82.02

Index Value Value – avg

===========================

0 56.70 -25.32

1 78.90 -3.12

2 23.50 -58.52

3 111.50 29.48

4 114.70 32.68

5 99.99 17.97

6 88.88 6.86

The elements with even subscripts are:

Index Value

=============

0 56.70

2 23.50

4 114.70

6 88.88

The sum of the elements with even subscripts = 283.78

The elements with odd subscripts are:

Index Value

=============

1 78.90

3 111.50

5 99.99

The sum of the elements with odd subscripts = 290.39

Do you want to continue(Y/N): y

Enter array size: -4

ERROR! Should be positive and

Now enter 10 values:

112 34.5 77.88 55.77 44.7 33.6 117.89 36.78 119.69 56.12

The array elements are:

112.00 34.50 77.88 55.77 44.70 33.60 117.89 36.78 119.69 56.12

The average value = 68.89

Index Value Value – avg

===========================

0 112.00 43.11

1 34.50 -34.39

2 77.88 8.99

3 55.77 -13.12

4 44.70 -24.19

5 33.60 -35.29

6 117.89 49.00

7 36.78 -32.11

8 119.69 50.80

9 56.12 -12.77

The elements with even subscripts are:

Index Value

=============

0 112.00

2 77.88

4 44.70

6 117.89

8 119.69

The sum of the elements with even subscripts = 472.16

The elements with odd subscripts are:

Index Value

=============

1 34.50

3 55.77

5 33.60

7 36.78

9 56.12

The sum of the elements with odd subscripts = 216.77

Do you want to continue(Y/N): n ……………………IN java…i am so confused on how to do this

i have this so far:

import java.util.*;
public class Assign4_1{
public static final int MAX = 10;
public static void main(String[] args){
Scanner input = new Scanner(System.in);
char ans;
int size;
double values;
System.out.print(“Do you want to start(Y/N): “);
ans = input.next().charAt(0);
while(ans == &#39;y&#39; || ans == &#39;Y&#39;){
System.out.print(“Enter array size: “);
size = input.nextInt();
while(size < 0 || size > MAX){
System.out.print(“ERROR! Should be positive and less than 10. Reenter: “);
size = input.nextInt();
}
int[] a = new int[size];
System.out.print(“Now enter ” + size + ” values: “);