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
GarryVolchara [31]
4 years ago
14

Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al

low the user to guess three numbers. Compare each of the user’s guesses to the three random numbers and display a message that includes the user’s guess, the randomly determined three-digit number, and the amount of money the user has won as follows:

Computers and Technology
1 answer:
Pachacha [2.7K]4 years ago
5 0

The question is not complete! Here is the complete question and its answer!

Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Allow the user to guess three numbers. Compare each of the user’s guesses to the three random numbers and display a message that includes the user’s guess, the randomly determined three-digit number, and the amount of money the user has won as follows:

no matches: 0

any one matching: 10$  

two matching: 1000$  

three matching: 100000$  

Code with Explanation:

#include <iostream>

using namespace std;

int main()

{

int matches=0;

int guess_1, guess_2, guess_3;

int num_1, num_2, num_3;

// get 3 digits from the user

cout<<"Enter first guess digit 0 to 9"<<endl;

cin>>guess_1;

cout<<"Enter second guess digit 0 to 9"<<endl;

cin>>guess_2;

cout<<"Enter third guess digit 0 to 9"<<endl;

cin>>guess_3;

// every time program runs srand() generates new random numbers and rand()%10 makes sure that number is single digit 0 to 9

srand(time(NULL));

num_1=rand()%10;

cout<<"First lottery digit: "<<num_1<<endl;

num_2=rand()%10;

cout<<"Second lottery digit: "<<num_2<<endl;

num_3=rand()%10;

cout<<"Third lottery digit: "<<num_3<<endl;

// store random generated numbers and guess numbers in arrays to compare them

int num[3]= {num_1,num_2,num_3};

int guess[3]={guess_1,guess_2,guess_3};

// compare the arrays to find out how many are matching

   for(int i=0; i<3; i++)

   {

 for(int j=0; j<3; j++)

 {

  if(num[i]==guess[j])

  {    

   matches = matches + 1;

  }

 }

}

cout << "Total Matches are: " <<matches << endl;

// display reward according to the number of matches

if (matches==0)

cout<<"you won: $0"<<endl;

if (matches==1)

cout<<"you won: $10"<<endl;

if (matches==2)

cout<<"you won: $1000"<<endl;

if (matches==3)

cout<<"you won: $100000"<<endl;

return 0;

}

Output:

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

1

Enter third guess digit 0 to 9

5

First lottery digit: 3

Second lottery digit: 7

Third lottery digit: 2

Total Matches are: 1

You won: $10

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

3

Enter third guess digit 0 to 9

4

First lottery digit: 5

Second lottery digit: 4

Third lottery digit: 7

Total Matches are: 2

You won: $1000

You might be interested in
sometimes people who have been playing gta for a while are annoying, i was playing gta this weekend and was trying to escape, bu
murzikaleks [220]
Yeah I stopped playing cause of people like that, I’m sorry you had to deal w that op :) I hope you have a nice day
3 0
3 years ago
Read 2 more answers
When is it most appropriate to quote from an e-mail message in a response?
allochka39001 [22]
I would say *d. when the quote is a part of a series of e-mails written by more than one person.*

eskettit hope this helped.
4 0
3 years ago
Read 2 more answers
One critique of determining the effectiveness of the psychodynamic perspective is that its theories are too vague to test. t/f
Feliz [49]
TRUE

Psychodynamic theories are usually too vague to allow a clear scientific test. Modest support for central psychodynamic hypotheses has been provided by Empirical studies. Critics have in the past disputed very many aspects of psychoanalysis including whether it is indeed a science or not. However much this is so, psychoanalysis is a great idea in personality that should never be overlooked.






3 0
4 years ago
Read 2 more answers
5
vova2212 [387]

Answer:

Document

Explanation:

Document because after you structure your document together the way you like you can add pictures.

3 0
4 years ago
Read 2 more answers
How do Humza's videos counter hate speech and xenophobia
o-na [289]

Humza's videos counter hate speech and xenophobia as he doesn't let the negativity get to him, he tries and succeeds to make positive changes for unity.

<h3>What is xenophobia?</h3>

The fear or hate of everything that is viewed as being alien or weird is known as xenophobia. It is a manifestation of perceived conflict between an ingroup and an outgroup and may take the form of mistrust of one another's actions, a wish to have them removed, or concern over losing one's ethnic, racial, or national identity.

Simply described, xenophobia is the fear or dislike of strangers or foreigners; it manifests itself in prejudiced attitudes and behaviors and frequently ends in violence, abuse of any kind, and displays of hatred. In this case, it should be noted that he preached love and the importance of being united.

Therefore, Humza's videos counter hate speech and xenophobia as he doesn't let the negativity get to him, he tries and succeeds to make positive changes for unity.

Learn more about xenophobia on:

brainly.com/question/24366668

#SPJ1

8 0
2 years ago
Other questions:
  • 50+ POINTS AND BRAIN IF CORRECT Chris is working with other employees on a worksheet. The other employees have made comments, bu
    8·1 answer
  • If you were optimizing for performance and wanted to support potentially adding many new elements to an adt, then:
    12·1 answer
  • One governing factor when determining the minimum size of conduit to be used is the 
    9·2 answers
  • Can you answer your own question on brainly?
    12·2 answers
  • The functions of forums
    15·1 answer
  • CIST 1122 Project 2 Instructions
    11·1 answer
  • Write a method called sum with a while loop that adds up all numbers between two numbers a and b. The values for a and b can be
    11·2 answers
  • A(n) ___________ operating system provides process and memory management services that allow two or more tasks, jobs, or program
    6·1 answer
  • One advantage of taking photographs under fluorescent light is that: Group of answer choices
    15·1 answer
  • a transport layer security (tls) virtual private network (vpn) requires a remote access server listening on port 443 to encrypt
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!