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
A carpenter sands a wooden board until it is smooth. Is this a physical or a chemical change?
exis [7]

This is a physical change. Because he is not changing what it is just its outward appearance. hope this helped.
7 0
3 years ago
Read 2 more answers
ASAP 20 Points please hurry
inna [77]

Answer:

All you got to do is type System.out printIn("Study English) etc...

Explanation:

Look at the answer to see if it is right.

7 0
4 years ago
Hi! Can you guys help me with these Java programming questions?
olchik [2.2K]
5. Answer 4
6. Answer 2
7 0
4 years ago
Write the steps to open an existing file in MS Word.​
777dan777 [17]

Explanation:

Choose Open from the File menu. The Open a File dialog box lists files and folders in your current folder. ...

Select the name of the document you want to open, or type the document name in the Enter file name field.

Press Return or click OK.

4 0
2 years ago
Read 2 more answers
Kelly has joined Drake's team. Drake sends Kelly an email explaining details of the project that she will be working on. Which o
Law Incorporation [45]
What are the options?
3 0
3 years ago
Other questions:
  • What is the size of a typical business card?
    11·2 answers
  • Why is the total number of cylinders in an engine an even number?
    11·1 answer
  • A ________ editor was the dominant way film was edited up until the early '90s.
    7·2 answers
  • True or false, alcohol tends to produce passive behavior in most people
    8·2 answers
  • Which registry hive is loaded first during windows startup?
    5·1 answer
  • Describe any four rights of users of information systems.
    8·1 answer
  • Personality traits such as thoughtfulness, empathy, self-control, and goal orientation belong to the _____ category.
    5·2 answers
  • Why is it important to organize your computer files?<br><br> “With a explanation”
    6·1 answer
  • What are your thoughts about this re-designed Logo? Is it good? Or is poorly designed? Explain your answer below.
    13·1 answer
  • Lucy wants to access the webpage. She is using her computer to access the webpage. What types of information will be in one fram
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!