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]
3 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]3 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
Technical skills are also called soft skills.<br> Question 9 options:<br> True<br> False
mestny [16]

The statement is false, technical skills are those that serve to perform a specific function and are also called hard skills.

Technical skills are skills that include knowledge in the mechanical, computer, mathematical or scientific area that will allow a good performance of specific tasks.

  • A person with technical or hard skills is able to apply specific methods, procedures and techniques in a specialized field.

  • Soft skills refers to the characteristics and personal competencies that show how a person copes with others, it is related to emotional intelligence.

Therefore, we can conclude that technical or hard skills are the practical knowledge necessary to perform specific tasks, while soft skills are those skills associated with the ability to interact effectively on a personal level.

Learn more about technical skills here: brainly.com/question/10976877

8 0
2 years ago
Function of an actuator
RSB [31]

Answer:

an actuator is a device that uses a form of power to convert a control signal into mechanical motion

6 0
3 years ago
Read 2 more answers
Which of the following statements is false?
mart [117]

Answer:

3 is true others are false

3 0
2 years ago
Read 2 more answers
In your opinion, why did Proponents<br>of IPs used IPV6 instead of IPv5​
frutty [35]

Answer:

The following where many reasons why IPv6 was used instead of IPv5 which are the limitation of it's 32 bit address, IPv5 began or used with a different name called Internet streaming, IPv6 provides unlimited addressing, because it comprises of 128 bit.

Explanation:

Solution:

The following reasons why Proponents  of IPs used IPV6 instead of IPv5​ is stated as follows:

  • Due to its limited 32 bit addressing
  • IPv6 offers almost unlimited addressing because of its 128-bit addressing
  • IPv5 started under a different name which is internet stream(ST)
  • ST(Internet streaming) was developed for streaming video and voice
  • ST was developed by Apple, NeXT, and Sun Microsystems
  • ST was effective on specific frequency to carry out communication
5 0
2 years ago
Does woman hair grow over time in dayz?
zhenek [66]
It grows but not drastically but you’ll be able to see the difference of length in a few months or even years depending on the person.
6 0
3 years ago
Other questions:
  • In pre-shared key mode, a passphrase should be at least ________ characters long.
    15·1 answer
  • Which of the following statements is true of a database? a. It is a collection of unstructured data. b. It is accessed primarily
    14·1 answer
  • The purpose of the ________ element is to describe the contents of a table.
    15·1 answer
  • Define a JavaScript function named showGrades which does not have any parameters. Your function should create and return an arra
    5·1 answer
  • Write an expression to print each price in stock_prices. Sample output with inputs: 34.62 76.30 85.05
    9·1 answer
  • In the layers toolbar, which layer will appear in front of your game
    9·1 answer
  • Which of the following would allow for the QUICKEST restoration of a server into a warm recovery site in a case in which server
    10·1 answer
  • The _____ method randomly rearranges the items in the list provided in the parentheses.
    5·2 answers
  • JAVA
    12·1 answer
  • Why might you use the More button in the Find and Replace dialog box?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!