Question
I need help making the following code so that you can pick your own lottery numbers and the random winning numbers that are picked each
I need help making the following code so that you can pick your own lottery numbers and the random winning numbers that are picked each week are shown
import java.util.*; enum lottryDays {
WED, SAT
} public class Megabucks {
private static int winning_count = 0;
public static int weeks = 52;
public static int randomNumber() {
return (int) (1 + 41 * Math.random());
}
public static void main(String[] args) {
List
while(patronsNumber.size()!=6) {
int number = randomNumber();
if(patronsNumber.contains(number)) {
}else {
patronsNumber.add(number);
}
}
System.out.println("Patrons number are " + patronsNumber);
for (int i = 0; i < weeks; i++) {
for (lottryDays val : lottryDays.values()) {
MegaBucksRC draw = new MegaBucksRC();
if (draw.hasWon(patronsNumber)) {
winning_count++;
System.out.println("6 of 42");
} else {
String res = draw.matches(patronsNumber)+" of 6 Numbers";
if(draw.containsBonusNumber(patronsNumber)) {
res = res+"+bonus number";
}
System.out.println(res);
}
}
}
System.out.println("Lotteries Won: "+winning_count);
} }
import java.util.*; public class MegaBucksRC {
private int[] frequencyArray = new int[42];
private ArrayList
public MegaBucksRC() {
while (numbers.size() != 7) {
int number = randomNumber();
if (!numbers.contains(number)) {
if (numbers.size() < 6) {
updateFrequency(number);
}
numbers.add(number);
}
}
}
private void updateFrequency(int i) {
frequencyArray[i] = 1;
}
private int randomNumber() {
return (int) (1 + 41 * Math.random());
}
public int matches(List
int count = 0;
boolean res = false;
for (int i = 0; i < patronsNumber.size(); i++) {
if (patronsNumber.contains(numbers.get(i))) {
count++;
}
}
return count;
}
public boolean containsBonusNumber(List
return patronsNumber.contains(numbers.get(6));
}
public boolean hasWon(List
boolean res = false;
if(matches(patronsNumber)==6) {
res = true;
}else if(matches(patronsNumber)==5 && containsBonusNumber(patronsNumber)) {
res = true;
}else {
res = false;
}
return res;
}
public List numbers() {
return numbers;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started