-3

I need to make an array populated with 28 random numbers and 2 others: 1 and -100. Following I was able to produce the random numbers all between 20 and 100; however, I don't know how to set [0] and [1] to 1 and -100.

    for ( int i = 2 ; i < prizeBoxes.length ; i++) {
        
        prizeBoxes[i] = (int) Math.floor(Math.random()*(max-min) +min);

    }
A1exandr Belan
  • 4,442
  • 3
  • 26
  • 48

1 Answers1

-3
public void initializeBoxes () {

prizeBoxes[0] = 1;
prizeBoxes[1] = -100;

    int min = 20;
    int max = 100;  

for ( int i = 2 ; i < prizeBoxes.length ; i++) {
        
    
     prizeBoxes[i] = (int) Math.floor(Math.random()*(max-min) +min);

    }

for ( int i=0; i < prizeBoxes.length ; i++){
System.out.println(prizeBoxes[i]) ;

    }

}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 07 '22 at 16:08