-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLottery | Guess | Random
More file actions
28 lines (28 loc) · 1.19 KB
/
Copy pathLottery | Guess | Random
File metadata and controls
28 lines (28 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class Practice{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Generate a lottery number
int lotteryNum = 10+(int)(Math.random()*90);
//System.out.println(lotteryNum);
int num1 = lotteryNum / 10;
int num2 = lotteryNum % 10;
//User Input
System.out.print("Enter Lottery guess number: ");
byte guessUserNumber = input.nextByte();
//-----------------------------------
//User num1 & num2
int guessNum1 = guessUserNumber / 10;
int guessNum2 = guessUserNumber % 10;
//----------------------------------
if (lotteryNum == guessUserNumber)
System.out.println("Exact match: you win $10,000");
else if (guessNum1 == num2 && guessNum2 == num1)
System.out.println("Match all digits: you win $3,000");
else if (guessNum1 == num1 || guessNum2 == num2 || guessNum1==num2 || guessNum2 == num1)
System.out.println("Match one digit: you win $1,000");
else
System.out.println("Sorry, no match");
System.out.println("The Lottery number is : "+lotteryNum);
}
}