While loop
Mon Oct 31 2022 04:19:44 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
// Importing the Random library
import java.util.Random;
class LuckyFive {
public static void main(String[] args) {
// Creating a random number generator
Random randomGenerator = new Random();
// Generate a number between 1 and 6
int dieRoll = randomGenerator.nextInt(6) + 1;
// Repeat while roll isn't 5
while (dieRoll != 5) {
System.out.println(dieRoll);
dieRoll =5;
}
}
}
content_copyCOPY
Comments