import java.util.Random;
class sorted_Bohan {
public static void greater (int[] n){
for (int i = 0 ; i!=6; i++){
if ( n [i] > 10){
System.out.print (n+" ");
}
}
}
public static void count (int[] n){
int c =0;
int c2 =0;
c2++;
if (n[c2] < 0){
c+=c;
System.out.print (n+" ");
}else if (c2 == 6 && n[c2]<0){
System.out.print (n+""+c+"negative numbers");
}else {
System.out.print (c+"negative numbers");
}
}
public static int [] sorted (){
for (int i = 0 ; i !=5 ; i++){
if (numbers[i]>numbers[i++]){
int temp = numbers[i];
numbers[i] = numbers[i++];
numbers[i++] = temp;
return numbers [i];
}
}
}
public static int [ ] reverse (){
for (int i = 6; i != 0; i--){
return numbers[i];
}
}
public static void main (String[] args){
Random generator = new Random ();
int numbers [] = null;
for (int i = 0 ; i != 6 ; i++){
numbers [i] = generator.nextInt (50 - -50 + 1) - 50;
count(numbers);
greater(numbers);
sorted ();
}
reverse ();
}
}
Hi,
I don’t know what you are trying to accomplish, but a method exits as soon as a return statement is reached. In your reverse() method that means the loop is redundant, because return numbers[i]
is always reached on the first iteration.
1 Like
I don’t know what your objective is, but since in all lines, numbers
is underlined. I’m guessing that the numbers
array is incorrectly defined.
1 Like