A LOTTERY GAME Assignment P2 IST210 1
Guideline Use the PHP you learnt in class to make a PHP page Game rules: Generate a random number x in [1,3] as the lucky number Generate a random number y in [1,3] as your number If y is the same as x, output “you win the game” y times in different headings; otherwise, output “lose the game” y times in different headings See next two slides for more details IST210 2
3 Heading 1 Font of the number: color red, size 5 Font of the number: color green, size 5 Font: color green in heading 1,2,3 Repeat 3 times (because your number is the same as the lucky number- you win- and 3 is the your random number)
IST210 4 Heading 1 Font of the number: color red, size 5 Font of the number: color green, size 5 Font: color red, heading 1,2 Repeat 2 times (because 2 is the your random number)
Hint Use rand(1,3) to generate a random number in [1,3] Use two variables, $x and $y, to store the rand number Use IF/ELSE to check whether $x and $y is the same Use FOR loop to echo the results $y times IST210 5
More hint IST210 6 <?php $x = rand(1,10); echo "The first random number is $x "; echo " "; $y = rand(1,10); echo "The second random number is $y "; ?> Random number between 1 and 10 Font: color red, size 5 Random number between 1 and 10 Font: color green, size 5
Submit Submit to ANGEL in Assignment P2 Your php script (as attachment) Link to the webpage you made (in the submission ) IST210 7