so in short, I need to randomly generate 6 numbers between 1-1000, and the 6 numbers added together must equal 1000
here's what I have so far
public static void main(String[] args){
Scanner keybd= new Scanner(System.in);
System.out.println("In 1000 rolls of dice, I got: ");
int sum = 0;
for(int side=1; side<= 6; side++){
int number = (int)(Math.random() * 1000 + 1);
System.out.println(side + "‘s " + (number);
sum = sum + number;
}
}
}
All it does is just print out 6 random numbers between 1-1000
I just can't figure out how to make it so that the numbers added together equal 1000
Any help will be appreciated!
Aucun commentaire:
Enregistrer un commentaire