Question concerning loops
I have to write a program that generates 1000 random integers between 1 and 10 and finds how many are less than or equal to 5 and how many are more than five. Here is the code I have written, which is not right. The problem is that I cannot figure out what I am doing wrong. I think it might have to do with the i++ I have in the for statement, but I am not sure. I do not know what to replace it with and if I leave it blank the program becomes an infinite loop.
Code:
public class PracticeExercise2A {
public static void main(String[] args){
//generate random number between one and ten one thousand times
//perform for loop
for(int i = (int)(Math.random()*(10) + 1); i <= 1000; i++){
if(i <= 5)
System.out.println("There are " + i + " numbers less than or equal to 5");
else
System.out.println("There are " + i + " numbers greater than 5");
}
}
}