# Help with assignment regarding arrays

So, I understand most of this, however I am at a loss as to how to figure out this final part. First off, here is my code currently.

[code]import java.util.*;
public class TestArray
{
public static void main(String [] args)
{
Scanner keyIn = new Scanner (System.in);

//read the array size from the keyboard
System.out.print("How big is the array?: ");
int [] test = new int [keyIn.nextInt()];
System.out.println("Enter " +test+" whole numbers: ");
//initialize the array with the values typed at the keyboard
for (int i=0; i num[i])
smallest= num[i];
return smallest;
}
}[/code]

-----------------------------

And here is the output of how the finished program is supposed to look.

How big is the array? 20
Enter 20 whole numbers: 92 71 20 13 18 65 21 72 97 81 73 22 87 19 99 100 64 29 45 88

The array contains:
92 71 20 13 18 65 21 72 97 81
73 22 87 19 99 100 64 29 45 88

The smallest element is: 13

Numbers of array elements less than 33: 7

The contents of the array after adding 10 to each element:
102 81 30 23 28 75 31 82 107 91
83 32 97 29 109 110 74 39 55 98

The contents of the array after subtracting 10 from each element:
92 71 30 23 28 65 31 72 97 81
73 32 87 29 99 100 64 39 45 88

Do it again? Y or y for yes, N or n for no: N

------------------------------------

I have the code for everything until "Numbers of array elements less than 33" which I am struggling to figure out. Any help with this would be appreciated. Thanks in advance

• This code should work.
[code]import java.util.*;

public class TestArray
{
public static void main(String [] args)
{
Scanner keyIn = new Scanner (System.in);

System.out.print("How big is the array?: ");
int [] test = new int [keyIn.nextInt()];

System.out.println("Enter " + test.length +" whole numbers: ");

for (int i=0; i < test.length; i++)
{
test[i] = keyIn.nextInt();
}

Smallest(test);
Subtract(test);
}

public static void Smallest(int[] num)
{
int smallest = num[0];

for (int i = 0; i < num.length; i++) {
if (num[i] < smallest)
smallest = num[i];
}
System.out.println("
The Smallest number in the array is: " + smallest);
}

{
System.out.println("
The contents of the array after Adding 10 from each element: ");
for (int i = 0; i < num.length; i++)
System.out.print((num[i] + 10) + " ");

}

public static void Subtract(int[] num)
{
System.out.println("
The contents of the array after subtracting 10 from each element: ");
for (int i = 0; i < num.length; i++)
System.out.print((num[i] - 10) + " ");
}
}[/code]

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!