-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLottery.java
41 lines (34 loc) · 1.45 KB
/
Lottery.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.*;
public class Lottery{
public static void main(String [] args){
Scanner userInput=new Scanner(System.in);
//Random random=new Random();
System.out.println("Enter a two ditits number:");
int input=userInput.nextInt();
int userFirst=input/10;
int userLast=input%10;
//System.out.println("First number is "+userFirst);
//System.out.println("Second number is "+userLast);
int a=(int)(Math.random()*100);
//System.out.println("Lottery number is "+a);
int lottFirst=a/10;
int lottLast=a%10;
//System.out.println("First number is "+lottFirst);
//System.out.println("Second number is "+lottLast);
if(input==a)
{
System.out.println("You have won $100000"+" \n\t\t***Lottery number is "+a+"***");
}
else if((lottFirst==userFirst ||lottFirst==userLast) && (lottLast==userFirst || lottLast==userLast))
{
System.out.println("You have won $50000"+" \n\t\t***Lottery number is "+a+"***");
}
else if((lottFirst==userFirst ||lottFirst==userLast) || (lottLast==userFirst || lottLast==userLast))
{
System.out.println("You have won $25000"+" \n\t\t***Lottery number is "+a+"***");
}
else{
System.out.println("You lose"+" \n\t\t***Lottery number is "+a+"***");
}
}
}