Keno is a great way to lose a lot of money. Occassionally, someone will win a bi
ID: 665560 • Letter: K
Question
Keno is a great way to lose a lot of money. Occassionally, someone will win a big jackpot, but it is rare. In this project, you will allow the user to pick anywhere from 1 to 15 numbers between 1 and 80. Then get the user's bet in whole dollar amounts. The computer will then pick 20 numbers. Your program will then figure out how many of the player's numbers match the computer's. Using the following table (Click to open PDF), your program will find the multiplier for calculating the payout. If the SPOT (number of numbers the user initially chose) is 6 and the CATCH (how many of the user's numbers matched the computer's) was 5, you would multiply 30 times the amount bet.
Make sure the user only enters numbers between 1 and 80 and that they do not enter any duplicates. Same for the computer, but the computer picks 20 numbers. Java Jcreator using a scanner object. Thanks in advance!
here is how the table would look like:
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //1
{1, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2
{1, 2, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //3
{0.5, 2, 6, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4
{0.5, 1, 3, 15, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},//5
{0.5, 1, 2, 3, 30, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0},//6
{0.5, 0.5, 1, 6, 12, 36, 100, 0, 0, 0, 0, 0, 0, 0, 0},//7
{0.5, 0.5, 1, 3, 6, 19, 90, 720, 0, 0, 0, 0, 0, 0, 0},//8
{0.5, 0.5, 1, 2, 4, 8, 20, 80, 1200, 0, 0, 0, 0, 0, 0},//9
{0, 0.5, 1, 2, 3, 5, 10, 30, 600, 1800, 0, 0, 0, 0, 0},//10
{0, 0.5, 1, 1, 2, 6, 15, 25, 180, 1000, 3000, 0, 0, 0, 0},//11
{0, 0, 0.5, 1, 2, 4, 24, 72, 250, 500, 2000, 4000, 0, 0, 0},//12
{0, 0, 0.5, 0.5, 3, 4, 5, 20, 80, 240, 500, 3000, 6000, 0, 0},//13
{0, 0, 0.5, 0.5, 2, 3, 5, 12, 50, 150, 500, 1000, 2000, 7500, 0},//14
{0, 0, 0.5, 0.5, 1, 2, 5, 15, 50, 150, 300, 600, 1200, 2500, 10000}//15
Explanation / Answer
small = "abcdefghijklmnopqrstuvwxyz"
02
big = small.upper()
03
size = len(big)-1
04
05
def encipher(S, n = 3):
06
finale_str = ''
07
for c in S:
08
if c.islower():
09
if (small.find(c)+n)>size:
10
c = small[(small.find(c)+n)-(size+1)]
11
else:
12
c = small[small.find(c)+n]
13
elif c.isupper():
14
if (big.find(c)+n)>size:
15
c = big[(big.find(c)+n)-(size+1)]
16
else:
17
c = big[big.find(c)+n]
18
finale_str += c
19
return finale_str
20
21
def decipher(S, n = 3):
22
finale_str = ''
23
for c in S:
24
if c.islower():
25
if (small.find(c)-n)<0:
26
c = small[size-small.find(c)-(n-1)]
27
else:
28
c = small[small.find(c)-n]
29
elif c.isupper():
30
if (big.find(c)-n)<0:
31
c = big[size-big.find(c)-(n-1)]
32
else:
33
c = big[big.find(c)-n]
34
finale_str += c
35
return finale_str
36
37
# Encipher examples...
38
print encipher("abcdefghijklmnopqrstuvwxyz", 1)
39
print encipher("abcdefghijklmnopqrstuvwxyz", 2)
40
print encipher("abcdefghijklmnopqrstuvwxyz")
41
42
print encipher("v0id is me!", 1)
43
print encipher("v0id is me!", 2)
44
print encipher("v0id is me!")
45
46
print " "
47
48
# Decipher examples...
49
print decipher("x0kf ku og!", 1)
50
print decipher("x0kf ku og!", 2)
51
print decipher("x0kf ku og!")
52
53
print " "
54
55
# Both...
56
string = "Dream.In.Code!"
57
print string
58
print encipher(string)
59
print decipher(string)
60
print decipher(encipher(string))
61
print encipher(decipher(string))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.