-
Notifications
You must be signed in to change notification settings - Fork 1
Math.random
Sharina Stubbs edited this page Jan 7, 2020
·
1 revision
math.Random returns a double, per the docs. Check out docs.oracle.com on Math.
double rand = Math.random();
int year = (int) Math.ceil(rand * 2020);
System.out.println(String.format("The year is %d.", year));
if(isLucky(year)) {
System.out.println("so lucky!");
} else {
System.out.println("try again!");