In HTML/JavaScript Create a web page that simulates a lottery. The JavaScript pr
ID: 3735316 • Letter: I
Question
In HTML/JavaScript
Create a web page that simulates a lottery. The JavaScript program will create an array of six numbers between 1 and 40 (inclusive). The numbers will be generated randomly. Be sure to check that the array does not contain duplicates . Sort the array in ascending order. Next, have the user enter the six numbers from an imaginary lottery ticket the user purchased. Sort, if necessary. Check to see how much, if anything, the user has won, using the following table of possible winnings:
The page should display the winning number, the user’s number, the number of matches (if any) and the winnings (if any). Save the page with the filename lottery.html. Submit your work as instructed by your teacher.
Number of Matches Amount of Winnings S 5.00 4 $ 50.00 100.00 100,000.00Explanation / Answer
Here is the code in C# and python ,you can take reference from it..
A pair of ticket ids results in the winning scenario if every bit from to is set in the bitwise OR of mask of both the tickets, i.e if it's equal to (1111111111)2 = (1023)10.
Now we iterate over all pairs of masks whose bitwise OR is equal to 1023 and add the number of ways.
Code Snippet
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.