Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

M-3 Create a Lottery

Create a lottery that creates a  random number from 1 to 100. This is the lucky number.

Create a random number from 1 to 100 for the user. This is users number.

If the user's number is the lucky number then the user wins 100$.

If the absolute difference between user's number and the lucky number is less or equal to ten, then the user wins 100$ minus 10$ for every number in between. 

Example: The lucky numbers is 85 and the usersNumber is 77. The absolute difference is 8, so the user wins 20$ (100 - 8 * 10). If the usersNumber is 84, the user wins 90$ and so on.

In any other case the user wins nothing.

Print the lucky number, the user's number and the winnings of the user

Extra bonus: Run this lottery 100 times and calculate how much money have you given to winnings.