Answer to Question #33428 in Java | JSP | JSF for Jimbo

Question #33428
Write a program LotteryPrinter that picks a combination in a lottery. In this lottery, players, can choose 6 numbers (possibly repeated) between 1 and 49. Your program should print out a sentence such as "Play this combination—it'll make you rich!", followed by a lottery combination.
1
Expert's answer
2013-07-22T11:51:20-0400
import java.util.Random;


public class LotteryPrinter {
public static void main(String[] args) {
System.out.println("Play this combination - it'll make you rich!");
Random rnd = new Random();
for (int i = 0; i < 6; i++) {
System.out.print(rnd.nextInt(49) + 1);
System.out.print(" ");
}
System.out.println();
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Jimbo
22.07.13, 19:18

Awesome. Thank you

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS