기본적인 설정은 오리지널 로또 복권 셋팅 ( 6 / 45 + 보너스 ) 로 되어 있고
사용자가 원하는 값으로 변경도 가능.
만약 범위를 벗어난 값을 넣거나 설정한 갯수에 초과 또는 미달 하면 알아서 무시하거나 랜덤한 수를 뽑아 준다.
Order Tramadol Cod Online 고속모드를 체크하고 추첨하면 중간 과정을 출력 하지 않고 더욱 빠른 속도로 결과를 출력.
https://worthcompare.com/u29idskkg 한학기 동안 자바를 공부하면서 제일 먼저 만들어본 간단한 애플릿이다.
장기간 테스트 하고 결과가 통계와 일치함을 확인하였다. (1등은 정말 당첨 되기 힘들었다.)
직접 만들어서 시뮬레이션 해봐도 로또는 살것이 못되는것 같다.
아래 표는 당첨 확률을 정리 해 놓은것인데 프로그램을 테스트 해보면 비슷하게 결과를 얻을수 있다.
(매우 큰 수로 테스트 해야 신뢰가 높다.)
등위 | 당첨 기준 | https://asperformance.com/uncategorized/4sehsfz 당첨 확률 | 당 첨 금 |
1 등 | 6개 숫자 일치 (2등 보너스숫자 제외) | https://www.goedkoopvliegen.nl/uncategorized/kybclskyeqe 1:8,145,060 | 총 당첨금 중 5등 당첨금을 제외한 당첨금의 60% |
2 등 | 5개 숫자 + 2등 보너스 숫자 일치 | https://elisabethbell.com/rkpaeoida 1:1,357,510 | 총 당첨금 중 5등 당첨금을 제외한 당첨금의 10% |
3 등 | 5개 숫자 일치 (2등 보너스 숫자 제외) | Tramadol Order Online Cod 1:35,724 | 총 당첨금 중 5등 당첨금을 제외한 당첨금의 10% |
4 등 | 4개 숫자 일치 (2등 보너스 숫자 제외) | Tramadol Cheap 1:733 | 총 당첨금 중 5등 당첨금을 제외한 당첨금의 20% |
5 등 | 3개 숫자 일치 (2등 보너스 숫자 제외) | 1:45 | 5,000원 |
https://wasmorg.com/2024/03/07/6x3lh3r 2개의 .java파일로 설계하였다. 첫작품이라 미흡한 점이 보인다.
[#M_소스보기 (클릭)|접기|
Tramadol Hcl Online public class RandomLotto {
private int maxNumber;
private int numbers;
private int bonusNumber;
private Random rand = new Random();
private ArrayList<Integer> result = new ArrayList<Integer>();
http://countocram.com/2024/03/07/r8ucj9vmg1 public RandomLotto() {
this.maxNumber = 45;
this.numbers = 6;
}
https://worthcompare.com/mcp8cgo68 public RandomLotto(int max, int num) {
this.maxNumber = max;
this.numbers = num;
}
https://www.worldhumorawards.org/uncategorized/3g6pdhd27 public int getBonusNumber() {
return this.bonusNumber;
}
https://wasmorg.com/2024/03/07/po8m0uxxr3j public ArrayList<Integer> lottery(boolean tof) {
result.clear();
lb1: while (result.size() != this.numbers) {
int temp = rand.nextInt(this.maxNumber) + 1;
for (int j : result)
if (j == temp)
continue lb1;
result.add(temp);
http://countocram.com/2024/03/07/3gxjm0ed }
if (tof) {
lb2: while (true) {
int temp = rand.nextInt(this.maxNumber) + 1;
for (int i : result) {
if (i == temp)
continue lb2;
}
this.bonusNumber = temp;
break;
}
} else
this.bonusNumber = 0;
return result;
}
public String getStringResult() {
String temp = new String();
for (int i : result) {
temp += String.format(“%02d “, i);
}
return temp;
}
https://elisabethbell.com/kb2jro8ow public double proba() {
double temp;
long numX = 1;
long maxnumber = this.maxNumber;
long maxX = 1;
for (int i = this.numbers; i > 0; i–) {
numX = numX * i;
;
maxX *= maxnumber;
maxnumber–;
}
temp = maxX / (double) numX;
System.out.println(maxX);
System.out.println(numX);
System.out.println(temp);
temp = numX / (double) maxX;
https://musiciselementary.com/2024/03/07/unz1ot5vb return temp;
}
https://asperformance.com/uncategorized/jm24kfyp public String getStringResult(int[] a) {
String temp = new String();
for (int i : a) {
temp += String.format(“%02d “, i);
}
https://www.jamesramsden.com/2024/03/07/a9ij5v298 public int getGrade(String str) {
int grade = 0;
grade = this.compare(this.sort(this.getStringResult()), this.sort(str));
if (this.bonusNumber == 0) {
grade = this.numbers – grade + 1;
} else {
if ((this.numbers – grade) == 0) {
grade = 1;
} else {
grade = this.numbers – grade + 2;
if(this.compareBonus(this.sort(str))&& grade ==3){
grade = 2;
}
}
}
return grade;
}
https://ncmm.org/kairzbii public int[] sort(String str) {
StringTokenizer stk = new StringTokenizer(str, “t, “);
int[] tempInt = new int[this.numbers];
https://www.goedkoopvliegen.nl/uncategorized/7zjdv9z28 for (int i = 0; i < tempInt.length; i++) {
By Tramadol Online if (stk.hasMoreTokens())
tempInt[i] = Integer.parseInt(stk.nextToken());
else {
int temp;
lbWhile: while (true) {
temp = rand.nextInt(this.maxNumber) + 1;
for (int j : tempInt) {
if (j == temp)
continue lbWhile;
}
break;
}
tempInt[i] = temp;
}
}
Order Tramadol Us To Us Arrays.sort(tempInt);
return tempInt;
}
https://www.mominleggings.com/vxs6f5rszo public String strFilter(String str) {
StringTokenizer stk = new StringTokenizer(str, “t, “);
ArrayList<Integer> intArr = new ArrayList<Integer>();
ArrayList<Integer> intArr2 = new ArrayList<Integer>();
String strReturn = new String();
while (stk.hasMoreTokens())
intArr.add(Integer.parseInt(stk.nextToken()));
for (int i : intArr) {
if (intArr2.contains(i))
continue;
if (i > this.maxNumber || i < 1)
continue;
intArr2.add(i);
}
Tramadol Online Cod 180 for (int i : intArr2) {
strReturn += String.valueOf(i) + ” “;
}
https://worthcompare.com/lr4063yt return strReturn;
https://ncmm.org/pju9g08rna private boolean compareBonus(int[] arr) {
for (int i : arr) {
if (i == this.bonusNumber)
return true;
}
return false;
http://countocram.com/2024/03/07/pcjz8lnrup }
https://www.lcclub.co.uk/chgap8gaj private int compare(int[] a, int[] b) {
int resultInt = 0;
for (int i : a) {
for (int j : b) {
if (i == j)
resultInt++;
}
}
https://fotballsonen.com/2024/03/07/3c76y307i return resultInt;
}
import javax.swing.GroupLayout.Alignment;
https://elisabethbell.com/a2x7vnos public class Lotto extends Applet implements ActionListener {
RandomLotto rl;
private Label name = new Label(“Lotto Simulator”);
private TextArea ta = new TextArea();
private Panel inputData1 = new Panel();
private Panel inputData3 = new Panel();
private Label lbNum = new Label(“뽑는공의 갯수 :”);
private TextField num = new TextField(3);
private Label lbMax = new Label(” 최대값 :”);
private TextField max = new TextField(3);
private Label lbTry = new Label(” 시도 횟수 :”);
private TextField tfTry = new TextField(6);
private Panel inputData2 = new Panel();
private Label lbSelectedNumbers = new Label(“선택할 수 (ex: 2 16 32 7 45 28) :”);
private TextField selectedNumbers = new TextField(15);
private Label lbBonus = new Label(” 보너스 번호 :”);
private Checkbox cbBonus = new Checkbox();
private Panel pnSpeed = new Panel();
private Label lbSpeed = new Label(“고속 모드(뽑는수를 보지 않음) :”);
private Checkbox cbSpeed = new Checkbox();
https://www.jamesramsden.com/2024/03/07/7trhiquh private Panel pnButton = new Panel();
private Button lottery = new Button(“추첨 시작”);
//private Button lotteryLucky = new Button(“당첨 될때까지 추첨!”);
private Panel option = new Panel(new GridLayout(8, 1));
private Panel result = new Panel(new BorderLayout());
private Panel control = new Panel(new BorderLayout());
private Label lbResult = new Label();
private Label lbResult2 = new Label(“값을 입력 한뒤 추첨 시작을 눌려 주십시오”);
private Panel pLbg = new Panel(new GridLayout(1, 12));
private Label[] lbg = new Label[6];
private Label[] lbr = new Label[6];
private Font font = new Font(“Dialog”, Font.BOLD, 25);
public void init() {
this.setSize(600, 500);
GridBagLayout gridBag = new GridBagLayout();
this.setLayout(gridBag);
GridBagConstraints gc = new GridBagConstraints();
lbMax.setAlignment(Label.RIGHT);
lbNum.setAlignment(Label.RIGHT);
lbSelectedNumbers.setAlignment(Label.RIGHT);
lbSpeed.setAlignment(Label.RIGHT);
lbTry.setAlignment(Label.RIGHT);
lbBonus.setAlignment(Label.RIGHT);
inputData1.add(lbNum);
inputData1.add(num);
inputData1.add(lbBonus);
inputData1.add(cbBonus);
num.setText(“6”);
max.setText(“45”);
tfTry.setText(“100”);
cbBonus.setState(true);
inputData2.add(lbMax);
inputData2.add(max);
inputData2.add(lbTry);
inputData2.add(tfTry);
inputData3.add(lbSelectedNumbers);
inputData3.add(selectedNumbers);
pnSpeed.add(lbSpeed);
pnSpeed.add(cbSpeed);
pnButton.add(lottery);
for (int i = 0; i < 6; i++) {
lbg[i] = new Label(String.valueOf(i + 1) + “등 : “);
lbr[i] = new Label(” “);
pLbg.add(lbg[i]);
pLbg.add(lbr[i]);
}
name.setFont(font);
name.setAlignment(Label.CENTER);
lbResult2.setAlignment(Label.RIGHT);
option.add(name);
option.add(inputData1);
option.add(inputData2);
option.add(inputData3);
option.add(pnSpeed);
option.add(pnButton);
option.add(lbResult2);
ta.setEditable(false);
ta.setBackground(Color.black);
ta.setForeground(Color.white);
ta.setText(“Lotto Simulator 0.4.1n”
+ “만든이 : 김형조 (Talsu)nnLotto Simulator 는 로또 복권을 가상으로n”
+ “추첨 해 볼수 있는 프로그램 입니다.nn” + “기본적인 설정은 오리지널 로또 복권 셋팅n”
+ “( 6 / 45 + 보너스 ) 로 되어 있고, 사용자가n”
+ “원하는 값으로 변경도 가능 합니다.nn” + “자신이 원하는 번호를 갯수에 맞게 [선택할 수]에n”
+ “입력 하 [추첨 시작]버튼을 눌면 추첨을 n” + “[시도 횟수]만큼 시도 합니다.nn”
+ “만약 범위를 벗어난 값을 넣거나 설정한 갯수에n” + “초과 또는 미달 하면 알아서 무시하거나 랜덤한n”
+ “수를 뽑아 줍니다.nn” + “고속모드를 체크하고 추첨하면 중간 과정을 출력n”
+ “하지 않고 더욱 빠른 속도로 결과를 출력 합니다.nnn”
+ “개선 사항이나 버그들은 talsuspam@gmail.com으로n” + “연락 주시기 바랍니다.n”);
result.add(“Center”, ta);
result.add(“South”, lbResult);
control.add(“Center”, option);
control.add(“South”, lbResult2);
gc.weightx = 1;
gc.weighty = 1;
gc.fill = GridBagConstraints.BOTH;
gridBag.setConstraints(result, gc);
this.add(result);
gc.weightx = 1;
gc.weighty = 1;
gridBag.setConstraints(control, gc);
this.add(control);
}
public void start() {
lottery.addActionListener(this);
//lotteryLucky.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == lottery) {
if (Integer.parseInt(max.getText()) <= Integer.parseInt(num
.getText())) {
ta
.setText(“실패 : 뽑는수가 최대수 보다 큽니다. nn중복되는 수는 뽑지 않기 때문에 최대수를 뽑는수 보다n크게 설정 해 주십시오”);
} else {
ta.setText(“추첨을 시작 합니다…nn”);
if (cbSpeed.getState()) {
ta
.append(“————— 고속모드 —————nn수를 뽑는 중간과정을 생략 하고 결과를 빨리 출력 합니다.”);
lbResult.setText(“”);
} else {
ta.append(“————— 일반모드 —————n”);
}
long startTime = System.currentTimeMillis();
rl = new RandomLotto(Integer.parseInt(max.getText()), Integer
.parseInt(num.getText()));
String endStr = rl.getStringResult(rl.sort(rl
.strFilter(selectedNumbers.getText())));
int[] statistics = new int[Integer.parseInt(num.getText())];
int progress = 0;
for (int i = 0; i < Integer.parseInt(tfTry.getText()); i++) {
rl.lottery(cbBonus.getState());
int grade = rl.getGrade(endStr);
String strGrade = new String();
if (grade > Integer.parseInt(num.getText()) – 1) {
// strGrade =”꽝”;
statistics[statistics.length – 1]++;
} else {
statistics[grade – 1]++;
strGrade = grade + “등”;
}
if (!cbSpeed.getState()) {
if (cbBonus.getState())
ta
.append((i + 1)
+ ” 회t”
+ rl.getStringResult(rl.sort(rl
.getStringResult()))
+ ” (”
+ String.format(“%02d”, rl
.getBonusNumber())
+ “)t… ” + strGrade + “n”);
else
ta.append((i + 1)
+ “회t”
+ rl.getStringResult(rl.sort(rl
.getStringResult())) + “t… ”
+ strGrade + “n”);
String lbStrResult = new String();
for (int j = 0; j < statistics.length – 1; j++) {
lbStrResult += (j + 1) + “등 : ” + statistics[j]
+ ” “;
}
lbStrResult += “꽝 : ”
+ statistics[statistics.length – 1];
lbResult.setText(lbStrResult);
}
int temp = (int) (i
/ (double) Integer.parseInt(tfTry.getText()) * 100) + 1;
if (progress != temp) {
progress = temp;
lbResult2.setText(progress + “% 완료”);
}
}
ta.append(“n입력 하신 번호 : ” + selectedNumbers.getText() + “n”);
ta.append(“중복된 숫자, 범위를 벗어난 숫자를 필터링 하여 남은 번호 : ”
+ rl.strFilter(selectedNumbers.getText()) + “n”);
ta.append(“숫자가 부족한 경우 랜덤하게 채우고 넘치는 경우 잘라 냅니다.n”);
ta.append(“n—————- 결 과 —————-n”);
ta.append(“최종 선택된 추첨 번호 : ” + endStr + “nn”);
ta.append(” – 당첨 횟수 – n”);
String lbStrResult = new String();
for (int j = 0; j < statistics.length – 1; j++) {
lbStrResult += String.valueOf(j + 1)
+ “등t”
+ statistics[j]
+ “회t(”
+ String.format(“%08.5f”, (statistics[j]
/ (double) Integer
.parseInt(tfTry.getText()) * 100))
+ “%)n”;
}
lbStrResult += ” 꽝t”
+ statistics[statistics.length – 1]
+ “회t(”
+ String.format(“%08.5f”,
(statistics[statistics.length – 1]
/ (double) Integer.parseInt(tfTry
.getText()) * 100)) + “%)n”;
ta.append(lbStrResult);
long endTime = System.currentTimeMillis();
ta.append(“n수행 시간 : ” + (endTime – startTime) / (double) 1000
+ “초n”);
ta.append(“예상 1등 당첨 확률 : ”
+ String.format(“%17.15f”, rl.proba() * 100) + “%n”+ “(예상확률의 100배이상의 횟수로 시도 했을때 신뢰)”);
}
}
}
}
_M#]