# Game lottery

## The problem

Generate a lottery of a three digit numbers. The program prompts the user to enter a three-digit number and determines whether the user wins according to the following rules:

1. If the user input matches the lottery number in the exact order, the award is \$10,000.
2. If all the digits in the user input match all the digits in the lottery number, the award is \$3,000.
3. If one digit in the user input matches a digit in the lottery number, the award is \$1,000.

## Breaking it down

Using the input from the user combine with `lotteryNumber` we need to check each digit. Using java 8 stream and predicates will help in this routine. Let's walk through each condition. First checking if there is an exact match by comparing values. Next, creating a `Stream.of()` using `Stream.allMatch` will check if each of the digits equal the digit of the user. Next, using `anyMatch` will check if one of the digits match. If no digits match, give the sorry message.

## Output

Game lottery posted by on

Tagged: java, java-exercises-beginner, intro-to-java-10th-edition, and ch3

Share on: