1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
elixir [45]
3 years ago
5

Write a lottery program that will ask the user if they would like to pick 5 numbers (1-30) or if they would like to choose EZ Pi

ck where the computer randomly picks their 5 numbers at a cost of $1.00. Then you will give them a chance to also play the Next Chance drawing for an extra $1.00. They do not choose additional numbers for the Next Chance drawing. Once they have all of their selections complete, have the computer game generate the five random winning numbers and if they opted for the Next Chance drawing, select 4 more random numbers. Display all of the users numbers, all of the winning numbers, and display how much, if any, that the player has won based on the following information:
Computers and Technology
1 answer:
Llana [10]3 years ago
6 0

Answer:

Explanation:

The following code is written in Python and creates arrays for the user's numbers and the next chance numbers, it also creates a cost variable and a did_you_win variable. The function takes in the winning numbers as an array parameter. It asks all the necessary questions to generate data for all the variables and then compares the user's numbers to the winning numbers in order to detect if the user has won. Finally, it prints all the necessary information.

import random

def lottery(winning_numbers):

   user_numbers = []

   next_chance_drawing = []

   cost = 0

   did_you_win = "No"

   #print("Would you like to choose your own 5 numbers? Y or N")

   answer = input("Would you like to choose your own 5 numbers? Y or N: ")

   if answer.capitalize() == "Y":

       for x in range(5):

           user_numbers.append(input("Enter number " + str(x+1) + ": "))

   else:

       for x in range(5):

           user_numbers.append(random.randint(0,31))

           cost += 1

   next_chance = input("Would you like to enter a Next Chance drawing for $1.00? Y or N: ")

   if next_chance.capitalize() == "Y":

       for x in range(4):

           next_chance_drawing.append(random.randint(0, 31))

           cost += 1

           

   if user_numbers == winning_numbers or next_chance_drawing == winning_numbers:

       did_you_win = "Yes"

   print("User Numbers: " + str(user_numbers))

   print("Next Chance Numbers: " + str(next_chance_drawing))

   print("Cost: $" + str(cost))

   print("Did you win: " + did_you_win)

You might be interested in
How do i voice record on my (acual ipod itself) ipod nano 4th generation helppppppp
Olenka [21]

Answer: it is called voice memo search it on your settings

Explanation:

3 0
3 years ago
A keyboard shortcut to pasting in a document is to key _____.
m_a_m_a [10]
(Ctrl + V) is the shortcut for pasting.

Similarly, (Ctrl + C) is the shortcut for copying.
6 0
3 years ago
Which are examples of email client programs?<br> hand<br> are examples of email client programs.
goblinko [34]

Answer:

Please check the attachment,

Explanation:

Please check the attachment.

Download txt
4 0
3 years ago
What are the advantages and drawbacks of using solar energy
Ray Of Light [21]

upfront price, but dependent on how long you use it you will save money, also the power it provides per square inch is low but that will be solved with time.

5 0
3 years ago
Mix ‘em Let s1 and s2 be 2 c-strings of the same length. Write a function char* mixem(char*s1, char* s2) which returns a c-strin
Shkiper50 [21]

Answer:

See Explaination

Explanation:

#include <iostream>

#include <string.h>

using namespace std;

char *mixem(char *s1, char *s2);

int main() {

cout << mixem("abc", "123") << endl;

cout << mixem("def", "456") << endl;

return 0;

}

char *mixem(char *s1, char *s2) {

char *result = new char[1 + strlen(s1) + strlen(s2)];

char *p1 = s1;

char *p2 = s2;

char *p = result;

while (*p1 || *p2) {

if (*p1) {

*p = *p1;

p1++;

p++;

}

if (*p2) {

*p = *p2;

p2++;

p++;

}

}

*p = '\0';

return result;

}

5 0
3 years ago
Other questions:
  • How do rubrics increase learning?
    15·2 answers
  • Given the following stream of accesses to a 4-block fully associative cache with LRU replacement, determine whether the access i
    8·1 answer
  • When an attacker promotes themselves as reputable third-party advertisers to distribute their malware through the Web ads,
    15·1 answer
  • __________ is a protocol used by e-mail clients to download e-mails to your computer.
    14·1 answer
  • How do you calculate typing speed
    8·1 answer
  • Drag each label to the correct location on the image.
    7·1 answer
  • Define- Emerging technology
    14·1 answer
  • For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
    7·2 answers
  • I am having trouble with this python question. I am in a beginner level class also so any solution that isn't too complex would
    8·1 answer
  • Write a recursive decent algorithm for a java while statement, a Javas if statement , an logical/mathematical expression based o
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!