can you please write a .java with two cases. one case is chooseing 5 random numb
ID: 3886003 • Letter: C
Question
can you please write a .java with two cases. one case is chooseing 5 random numbers from the range of (1-36) and the second case is choosing a 6 randoms numbers form the range of (1-53).
also it would help if you used netbeans
and please give your algorithm
i was given this to generate random numbers hope it helps
Part 1: Picking those winning lottery numbers! Your mom loves playing the lottery each week, but she always takes forever to pick a set of numbers. It's driving you crazy because, who does she send to the store to get her lottery tickets? You! Wonderful child that you are, you've decided to help her by writing a program that will pick some numbers for her. Awesome! Think about how you can do this. Your mom likes to play both Fantasy 5 and the regular Lotto (6 numbers), so you want to write a program that takes this in account. o For Fantasy 5, the range of possible numbers should be from 1- 36 o For the Lotto, the range of possible numbers should be from 1- 53 Don't worry about whether you get duplicate numbers (we haven't learned enough about that yet) Assume that you will be given a method that gives you one random number. *Think about how you want to present her number picks to her. You'll want to be sure to great her and include some enthusiastic text along with her numbers (e.g. "Here are your winning numbers!") For Part 1, write an algorithm for your winning lottery number program, and then do several iterations of tests (i.e., step through your algorithm to make sure that it is logically correct and gives you the correct output). Put this in a Word or Open Office document. You'll turn that document in with the program that you create in Part 2Explanation / Answer
RandomNumbersCheck.java
import java.util.Random;
public class RandomNumbersCheck {
public static void main(String[] args) {
System.out.println("Here are your 5 digit winning number: ");
for(int i=0;i<5;i++) {
System.out.println(getRandomNumbers(1, 36));
}
System.out.println("Here are your 6 digit winning number: ");
for(int i=0;i<6;i++) {
System.out.println(getRandomNumbers(1, 53));
}
}
public static int getRandomNumbers(int lower, int upper) {
String s= "";
Random r = new Random();
return r.nextInt(upper)+lower;
}
}
Output:
Here are your 5 digit winning number:
1
12
14
21
35
Here are your 6 digit winning number:
40
27
37
30
8
50
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.