Fortune Telling Collection - Comprehensive fortune-telling - Java fortune-telling code _java fortune-telling system

Java fortune-telling code _java fortune-telling system

Writing two-color ball code with java program

Screenshot:

Red ball number selection method:

/**

? *? Randomly choose the red ball

? *?

? *? Get one of the numbers 1~33.

? *?

? *? 0? & lt=? Mathematical randomness? & lt? 1

? */

Private? int? randomOneRedValue()? {

int? randomValue? =? (int)? (Math.random()? *? 33? +? 1);

Return? randomValue

} How to choose the number of the blue ball:

/**

? *? Randomly choose the blue ball number.

? *?

? *? The value of 1~ 16 is obtained.

? *?

? *? @ Return

? */

Private? int? randomOneBlueValue()? {

int? randomValue? =? (int)? (Math.random()? *? 15? +? 1);

Return? randomValue

} test:

Public? Class? Test 1? {

Public? Static electricity Invalid? main(String[]? arg)? {

Test 1? localTest 1? =? New? test 1();

//? Two-color ball: red ball number? +? Blue ball number

//? Six red balls and a blue ball number.

//? The red ball number is selected from 1~33.

//? The number of the blue ball is selected from 1~ 16.

//? First prize: seven numbers match (six red numbers and one blue ball number) (the order of red ball numbers is not limited, the same below).

//? Second prize: number matching of six red balls;

//? Third prize: five red ball numbers, or four red ball numbers match a blue ball number;

//? Fourth prize: five red ball numbers, or three red ball numbers match a blue ball number;

//? Fifth prize: four red ball numbers, or three red ball numbers match a blue ball number;

//? Sixth prize: a blue ball number match (the wrong red ball number can match);

//? For example: red ball number? 0 1? 06? 13? 19? 24? 28? Blue ball number? 16

System.out.println ("start award");

//? Defines a two-color ball array of size 7.

String[]? Values? =? New? string[7];

For what? (int? Me? =? 0; ? Me? & lt? 7; ? i++)? {

What if? (me? ==? 6)? {

int? blueValue? =? localtest 1 . randomonebluevalue();

What if? (blueValue? & lt? 10)? {

Values [i]? =? "0"? +? blueValue

}? Or what? {

Values [i]? =? String.valueOf (blue value);

}

}? Or what? {

int? redValue? =? localtest 1 . randomoneredvalue();

What if? (redValue? & lt? 10)? {

Values [i]? =? "0"? +? redValue

}? Or what? {

Values [i]? =? string . value of(red value);

}

}

}

system . out . println();

System.out.println ("the award is over");

system . out . println();

System.out.print ("Two-color ball lottery number:");

//? Print two-color ball number

For what? (string? Value? :? Values)? {

System.out.print("? ? +? Value);

}

}

}