O GoConqr está de visual novo! Conte para nós o que você achou.

Módulo 7 de 10 · Mídia

Create a lottery

Kostas Diakogiannis

Create a lottery

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.

Instruções

Para avançar no curso, envie uma tentativa deste quiz. Você pode enviá-la depois da última pergunta.

Ir para o módulo escolhido

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?