Write a program that simulates a lottery. The program should havean array of five integers named lottery, and shouldgenerate a random number in the range of 0 through 9 for eachelement in the array. The user should enter five digits whichshould be stored in an integer array named user. Theprogram is to compare the corresponding elements in the two arraysand keep a count of the digits that match. For example, thefollowing shows the lottery array and the user array with samplenumbers stored in each. There are two matching digits (elements 2and 4).
lottery array: 7,4,9,1,3
user array: 4,2,9,7,3
The program should display the random numbers stored in the lotteryarray and the number of matching digits. If all the digits match,display a message proclaiming the user as a grand prize winner.

Answers

Answer 1

Answer:

Here is the C++ program that simulates lottery:

#include<iostream>  //to use input output functions

using namespace std;  //to access objects cin cout

int main(){  //start of main function

int size= 5; // size of arrays

int range = 10;  //range of random numbers from 0 to 9

int user[size];  // user array

int lottery[size];  // lottery array

for(int i=0;i<size;i++)  //iterates through the array

lottery[i]=rand()%range;  // generates random number in specified range

cout<<"Enter "<<size<<" digits: ";  //prompts user to enter 5 digits

for(int i=0;i<size;i++)  //loops through the user array

cin>>user[i];  //reads input digits from user

int match=0;  //stores number of matching digits

for(int i=0;i<size;i++)  //iterates through array to compare user and lottery arrays

if(user[i]==lottery[i])  //if digit at i-th index of user array matches to that of lottery array

match++;  //increments count of matching digits by 1

cout<<"Lottery array: ";  // display digits of lottery array

for(int i=0;i<size;i++)  //iterates through elements of lottery array

cout<<lottery[i]<<" ";  //prints elements of lottery array with a space between them

cout<<endl;  //prints a new line

cout<<"  User  array: ";  // prints digits of user array

for(int i=0;i<size;i++) //iterates through elements of user array

cout<<user[i]<<" ";  //prints elements of user array

cout<<endl;  // prints a new line

if(match==size){  //if all the digits match

cout<<"Congratulations. You are a grand prize winner! "; }//displays this message proclaiming the user as a grand prize winner

else{  // if all digits of user array do not match with lottery array digits

cout<<"Number of digits matched: "<<match<<endl; //displays the number of matched digits

cout<<"Sorry! Better luck next time!" ;    //displays this message when all digits don't match

}

}    

Explanation:

If you want to keep the size and range fixed then you can use #define before the main() function to give a constant value to size and range as:

#define size 5

#define range 10

The program uses rand() function in order to generate random numbers for lottery array in the range of 0 through 9.

Then the program declares a user array with size = 5 and prompts user to enter 5 digits to stores in user array.

Next the program matches each digit of user array to the corresponding digit of lottery array and if the two digits match then the program increments the match variable by 1 to count the matched digits. For example, lets say lottery has the following elements:

lottery: 7,4,9,1,3

Lets say user array has following elements input by user at console

user: 4,2,9,7,3

Now at first iteration the digit 7 at 0-th index of lottery array is matched to the digit 4 at 0-th index of user array. This index is specified using variable i. These means the first element of lottery array is matched with first element of user array. As these digits are not equal so they don't match and the variable i is incremented to point to the position of next digit.

Now at second iteration the digit 4 in lottery array is matched to the digit 2 of user array. As these digits are not equal so they don't match and the variable i is incremented.

at third iteration the digit 9 in lottery array is matched to the digit 9 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 1

Now at fourth iteration the digit 1 in lottery array is matched to the digit 7 of user array. As these digits are not equal so they don't match and the variable i is incremented. The value of match also remains the same i.e. 1

at fifth iteration the digit 3 in lottery array is matched to the digit 3 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 2

Next the loop ends because the value of exceeds 5 which is the size of the array.

Next if(match==size) statement has an if condition which checks if all digits match. This is checked by comparing the count of match variable to the size of the array. The value of match is 2 and value of size is 5 so this means that all the digits do not match. Hence this condition evaluates to false. So the statement in if part will not execute and program moves to the statement: cout<<"Number of digits matched: "<<match<<endl; which displays the value of match variable i.e. 2 as:

Number of digits matched: 2

followed by statement cout<<"Sorry! Better luck next time!" ;  which displays the message:

Sorry! Better luck next time!

Write A Program That Simulates A Lottery. The Program Should Havean Array Of Five Integers Named Lottery,

Related Questions

Which of the following is used to encrypt web application data?
a. MD5
b. AES
c. SHA
d. DHA

Answers

Answer:

b. AES

Explanation:

AES is an acronym for Advanced Encryption Standard and it is a cryptographic or symmetric block cipher that is based on a substitution-permutation network (SPN) used for the encryption of sensitive data over the internet or web. AES uses a key length of 128, 192 or 256 bits and a block length of 128 bits to encrypt data on web applications.

It is an encryption standard of the government of the United States of America and is supported by the National Institute of Standards and Technology (NIST).

Hence, AES is used to encrypt web application data and it uses an algorithm developed by Vincent Rijmen and Joan Daemen, known as the Rijndael algorithm.

When performing actions between your computer and one that is infected with a virus, which of the following offers No risk of your computer becoming infected?
A. Printing to the same printer as infected computer
B. Accepting email attachments sent from an infected computer
C. Sharing Word documents with an infected computer
D. Sharing removable disks with an infected computer

Answers

Answer:

d

Explanation:

The correct option is D: Sharing removable disks with an infected computer

Removable disks are disks that use to keep data as well transfer data or information from one computer to another computer.

With Removable disks a computer infected with a virus cannot infect another Computer as the what the user does is to simply insert  the USB port of the  Removable disks into the computer which inturn enable the transfer of data to the computer to take place .

Learn more about Removable disks here:

https://brainly.com/question/4327670

How has technology influenced space exploration?

Answers

Answer:

One of the biggest benefits of machine learning when it comes to space exploration is that programs can sift through the available data more easily than humans, which increases the chance of finding planets just by looking at datasets. It's even thought that AI could be instrumental in locating extra-terrestrial life.

Explanation:

An ISP is considering adding additional redundant connections to its network. Which of the following best describes why the company would choose to do so?

Answers

Answer:

Redundant networks are generally more reliable.

Explanation:

The complete question is in this brainly link;

https://brainly.com/question/18302186

This is based on knowing the importance of a redundant network.

C. Redundant networks are more reliable

A redundant network is one that helps to increase the reliability of a computer system.

Now, this is possible because the more critical the ISP NETWORK is, the more important it will be for the time it takes to resolve from a fault would be reduced.

This implies that, by adding one redundant device to their connection, the time it will take to resolve from a fault would be drastically reduced and this will lead to a far more reliable system.

Thus, redundant networks are more reliable.

Read more at; brainly.com/question/17878589

When computers are connected and operate through one main computer, it is called a _________ network. centralized client server GUI peer-peer

Answers

Answer:

the answer would be a client server

Explanation:

In a situation wherein computers are connected and operate through one main computer, it is called a client server network. Therefore, the option B holds true.

What is the significance of a client server network?

A client-server network can be referred to or considered as a network wherein all the systems that are collectively a part of the computer network are controlled and handled by a single system. This single system of computers is also known as the main computer.

The main computer has access to all the data, as well as information tracking of the activities performed by the main computer. In order to access anything between the different systems, the members systems need to get authorized access through the main computer.

Therefore, the option B holds true and states regarding the significance of a client server network.

Learn more about a client server network here:

https://brainly.com/question/28099574

#SPJ2

Clicking and double-clicking are two of the five

Answers

Answer:

The correct answer is events

Suppose you have a class Ship, which was written by another programmer who used to work for your employer. Ship is used in several different applications. Ship contains a public method called getBearing() that consults gyroscopes and a compass to determine the direction in which the ship is moving and returns a Location object. You need to refactor the code to use a GPS receiver instead. You should

Answers

Answer:

Research of the GPS features and the modules and packages needed by the programming language to implement and receive data from a GPS tracker.

Explanation:

The Ship class is a blueprint that holds a data structure of a ship's location in coordinates. The location variable can be changed using the getBearing method and an instance of the ship class can be made several times for different ships in the harbor. This class depicts the power of object-oriented programming.

Refactoring is a concept in software engineering where source codes are modified to achieve code efficiency and speed. All programming language source code should be refactored where needed with the right packages or modules.

Students who respond promptly to e-mails are following which netiquette rule?

A. keeping content appropriate
B. assessing an online environment
C. respecting everyone’s time
D. practicing ethical behaviors

Answers

Answer:

respecting everyone's time

Explanation:

they don't make people wait for a response

Its Option C - Respecting Everyone’s Time.
Thank you!

When does the VB.NET programming environment start to operate?
A. once a VB.NET project is compiled
B. once a VB.NET project is created in the Microsoft Visual Studio environment
C. once a VB.NET project is debugged
D. once a VB.NET project folder is opened
E. All of the above are correct

Answers

Answer:

B. once a VB.NET project is created in the Microsoft Visual Studio environment.

Explanation:

Visual Basic . Net is a programming language which is used to run complex software and projects. The VB projects which are created in Microsoft Visual Studio are run by console application. These computer applications run complex and technical software.

Proper numeric keyboarding technique includes all of these techniques except
O keeping your wrist straight
O resting your fingers gently on the home keys
O looking at the keys
O pressing the keys squarely in the center

Answers

The answer is looking at the keys

Answer: Its the 1st choice, 2nd choice, and the final one is the 4th one. (NOT the third answer choice)

Explanation: (I just took the test)... Hopefully this helps and good luck.

What do you think is the single greatest physical threat to information systems? Fire? Hurricanes? Sabotage? Terrorism? Something else? Discuss this question and provide support for your answer.

Answers

Answer:

The single greatest physical threat to information systems is:

Sabotage

Explanation:

Sabotage describes the efforts of internal persons to ensure that a system does not operate as intended or is destroyed.  Among the threats to information systems, this is the greatest.  The problem with sabotage is that the operators are internal, they know the system very well.  They understand the weak points and the strengths of the system.  They are internal terrorists to any information system.  These internal saboteurs are capable of using any means to achieve their purpose.  Therefore, it is necessary to scrutinize employees from time to time to discover internal risks.

What will be the result from running the following program? print grades print 92 print 80print total print 92+80

Answers

Answer:

Grades

92

80

Total

92 + 80

Explanation:

When utilizing quotations, you enable to code to print what wrote, as it is. So, instead of adding the 92 + 80, it's printed out.

I hope this helped!

Good luck <3

The question is in the picture

Answers

Answer:

nordthaf

Explanation:

nofth

Which of these browsers was the first widely adopted?
1. Internet Explorer
2. Chrome
3. Firefox
4. Netscape

Answers

Answer:

netscape

Explanation:

Which of the following could be defined as a general-purpose computing device that enables workers to create, manage, store, search for, and process information? MP3 player. Hard drive. Flash drive. Personal computer.

Answers

Hard drive is your answer

Answer:

It's personal computer

Explanation:

I got it right on my assignment

Question #1
What do you use to navigate through a file by moving the view
up and down or side to side?
O Title bar
O Ribbon
O Document area
O Scroll bar


Answers

d scroll bar be cause it’s a file which means computer

Answer:

Answer is the Scroll Bar

Explanation:

When you are in a document, the way you move around or navigate in it is by dragging the scroll bar that is to the left of your screen or at the bottom of your screen.  Hope this helps!

$8.25/hour; _____$/year, when working 40 hours a week.

Answers

if you work 50 weeks/year and 40 hours/week, you will make 16,500 dollars per year if you make 8.25 per hour

What is true about connectionless packet switched networks? a. each datagram must contain both source and destination addresses b. without a connection, datagrams may not arrive in sequential order at the destination c. establishment of a connection between communicating points is not required prior to exchanging datagrams, thus reducing overhead communications d. all of the above are true

Answers

Answer:

d. all of the above are true

Explanation:

Connectionless Packet Switching is a term that is used in computer networking operations to describe the breaking of information exchange path into a various packet of small sizes acquired and refined over network switches and routers, which is then transferred from one subsequent node to the other. It is sometimes referred to as Datagram Networks

However, during this operation, Connectionless Packet Switching must satisfy the following amongst others:

1.  each datagram must comprise both source and destination addresses

2.   without a connection, datagrams may not come in sequential order at the destination

3.  establishment of a connection between communicating points is not needed prior to exchanging datagrams, thus reducing overhead communications

Therefore, considering the available options, the correct answer is option D

How to Print output in JavaScript

Answers

If you want to print on a page you can use

document.write();

If you want to write in console then there are multiple options

console.log() - to log information

console.error();- to log errors

console.warn(); - to log warning message

If you want to popup some information the you can use -

alert(message);

there are also various options present in alert.

or

print() essentially just calls up the native print dialog for a given window.

But as you're are thinking, it will work on any window or (i)frame.

thus if you write content to a frame, you can then call this to print it.

window.frameName.print();

note the only drawback (and its a big one), is that this calls up the print dialog... not the print preview window... thus the user doesn't really get a chance to see what they are printing and/or scale it to fit their printer/paper.

I personally wish that all browsers would implement the following to handle the above issue.

window.printPreview();

Hope this will help !!!

Answer:

Just add "document.wright();" to print text.

How many bits are reserved for the Transmission Control Protocol (TCP) flags?

Answers

It’s 6 bits are reserved for the 6 TCP control flags. A connection, at which layer, implies that every segment of data sent is acknowledged? transport; A connection at the transport layer implies that every segment of data sent is acknowledged.

what is ovoviviparous? ​

Answers

Answer:

o·vo·vi·vip·a·rous

Explanation:

(of an animal) producing young by means of eggs which are hatched within the body of the parent, as in some snakes.

C++ code pls write the code

Answers

Answer:

Following are the code to this question:

#include<iostream>//defining header file

using namespace std;

class vec//defining class vec  

{

int x, y, z; //defining integer varaible x, y, z

public: // using public access specifier

vec() //defining default constructor

{

   x = 0; //assign value 0 in x variable  

   y = 0; //assign value 0 in y variable

   z = 0;//assign value 0 in z variable

}

vec(int a, int b , int c) //defining parameterized constructor vec

{

   x = a; //assign value a in x variable

   y = b; //assign value b in y variable

   z = c;//assign value c in z variable

}

void printVec() //defining a method printVec

{

   cout<<x<<","<<y<<","<<z<<endl; //use print method to print integer variable value

}

//code

vec& operator=(const vec& ob) //defining operator method that create object "ob" in parameter  

{

x=ob.x; //use ob to hold x variable value

y=ob.y;//use ob to hold y variable value

z=ob.z;//use ob to hold z variable value

return *this;//using this keyword to return value  

}

};

int main()//defining main method

{

vec v(1,2,3);//calling parameterized constructor

vec v2; //creating class object to call method

v2=v; //creatring reference of object

v2.printVec(); //call method printVec

return 0;

}

Output:

1, 2, 3

Explanation:

In the above-given code part, a method "operator" is defined, that accepts an object or we can say that it is a reference of the class "ob", which is a constant type. Inside the method, the object is used to store the integer variable value in its variable and use the return keyword with this point keyword to return its value.    

5. Which one of the following best defines a network server?
O A A type of network system that provides resources to network clients
B A type of system where all devices on the network are clients
C A type of network with one server and multiple clients
O D A type of device that connects all all other network devices together

Answers

Answer:

i thank it is B for the answer

edhesive 1.7 code practice question 1
Fix the error so that the code works correctly
input (“Enter a number: “)
print (num * 8)
How do I fix the error?

Answers

Answer:

num = int(input("Enter a number: "))

print(num * 8)

Explanation:

I highlighted the parts that are added

Since you are getting an input from the user, you need to set the result to a variable. In this case, it is num.

Since it is a number, you need to specify the its type. In this case, it may be int.

Also, the quotation marks must be written as seen.

The corrected program which ensures that the program runs correctly is written thus :

num = int(input("Enter a number: ")

#user supplied input should be assigned to the varibale num

print(num * 8)

#multiplies num by 8 and displays the output.

The num variable in the second line isn't attached to any value, therefore, it will throw an error.

The user input value should be attached to the variable, 'num'

The second line of code multiplies num by 8 and displays the product.

Therefore, if the the user input is 3 ; the final result displayed will be : (3 × 8) = 24.

Learn more :https://brainly.com/question/15566254

Which example of IT lifelong learning is most likely to lead to a promotion

Answers

Answer:

A supervisor learns about personal finance.

Hope the above answer helps u...

If my answer helped u mark me as brainlist..!

Follow me...

Answer:

A supervisor learns about personal finance.

Explanation:

Write code that determines the number of full days represented by the number of hours stored in the variable hours and stores that value in the variable full_days. For example, the number of full days in 50 hours is 2. Ignore any leftover hours that don't contribute to a full day. Assume the value of hours has already been initialized. Solve It!

Answers

Answer:

hours = 50

full_days = int(hours / 24)

print("The number of full days in " + str(hours) + " hours is " + str(full_days))

Explanation:

Initialize the hours

Since there are 24 hours in a full day, divide the hours by 24. Note that you need to typecast it to the int, because the result is a decimal value by default

Print the values as requested

What is the outside of an iPhone called?

Answers

What, what are you talking about

Sam card tray is the answer

Write a MATLAB function named average_of_scores_with_drops The function will have two inputs and two return values. The first input will be a list of scores. The second input will be a postive integer representing the number of scores to drop. It will not be larger than the length of the list. Your function should determine the average of the scores after dropping the specified number of lowest scores. The first return value must be a real number equal to the average score. The second return value must be the number of items that were averaged. Notes: Example Test Case: SCORES

Answers

Answer:

-%Define the function.

function [avg, ele_left] = average_of_scores_with_drops(input_list, drop_element)

%Sort the list.

input_list = sort(input_list);

%Compute the length of the list.

len_list = length(input_list);

%Declare and initialize the variable.

sum = 0;

%Increase the element to be drop by 1.

i = drop_element + 1;

%begin the for loop.

for k = i : length(input_list)

%Add the elements.

sum = sum + input_list(k);

%End of the for loop.  

end

%Compute the elements left after dropping the dropped element.

ele_left = length(input_list) - drop_element;

%Compute the average of the elements left.

avg = sum/ele_left;

%End of the function defined.

end

%Run the following code in the command prompt.

%Call the function and return the average

%score and the number of elements

%whose average is computed.

[average_score , number_of_items] = average_of_scores_with_drops([8 6 1 2 3 5 10], 2)

SAMPLE OF OUTPUT

average_score = 6.40000000000000

number_of_items = 5

For what purpose are high-level programming languages used for

1. Give control over the hardware to execute tasks quickly

2. Provide code that controls the computers hardware

3. Translate low-level programming languages into machine code

4. Write programs for general applications

Answers

Answer:

To speed up the compiler during run time

Explanation:

Your network administrator finds a virus in the network software. Fortunately, she was able to eliminate it before it resulted in a denial-of-service attack, which would have prevented legitimate users of the networked database from gaining access to the records needed. It turns out that the network software did not have adequate security protections in place. The fact that this virus was successfully inserted into the network software points to a ______ the network software.

Answers

Answer:

Vulnerability of.

Explanation:

In this scenario, your network administrator finds a virus in the network software. Fortunately, she was able to eliminate it before it resulted in a denial-of-service attack, which would have prevented legitimate users of the networked database from gaining access to the records needed. It turns out that the network software did not have adequate security protections in place. The fact that this virus was successfully inserted into the network software points to a vulnerability of the network software.

In Cybersecurity, vulnerability can be defined as any weakness, flaw or defect found in a software application or network and are exploitable by an attacker or hacker to gain an unauthorized access or privileges to sensitive data in a computer system.

This ultimately implies that, vulnerability in a network avail attackers or any threat agent the opportunity to leverage on the flaws, errors, weaknesses or defects found in order to compromise the security of the network.

Some of the ways to prevent vulnerability in a network are;

1. Ensure you use a very strong password with complexity through the use of alphanumerics.

2. You should use a two-way authentication service.

3. You should use encrypting software applications or services.

Other Questions
Sebastian plays a snare drum that has a radius of 3 inches. What is the drum's diameter? ______ inches Which is the best analysis of how Equiano uses characterization to develop a theme in this paragraph? 2. When people decide what makes a fair trade, like exchanging 2 chickens for 2 sheep, they are(1 point)OnegotiatingO exportingO importingO rating Please help!! Ive tried to answer this but Im off a few cents every time. Megans aunt have her a $100 gift card to Toys R Us for her birthday. Determine the price of the most expensive toy that Megan can buy with this gift card if the sales tax is currently 9.8% 2If A=4 3find A1 usingelementary row operations. What is a central idea in the story "Bul-GO!-gi" about the children of immigrants?A) They are pulled between the traditions of their parents' culture and the changes required by a new culture.B) They must face challenges with their parents because of generational differences.C) They decide whether to portray stories about growing up as humorous or challenging. D) They have to either work hard and succeed or be independent and well-liked. Question 2Part BWhich detail from the story supports the answer in Part A?A) "Still, she was determined not to force Seo-Jun to do the things her mother had forced her to do. He wouldn't have to take violin lessons, nor would he have to learn Korean."B) "...she'd made Ji-Suk take Korean lessons every Saturday morning followed by violin lessons in the afternoonand cooked kimchi and other Korean delicacies with her at least once a week..."C) "She was American, just as much as she was Korean, and even though her mother wouldn't have wanted her to do it, starting the food truck was Ji-Suk's way of honoring her mother and showing that she valued what her mother had taught her."D) "She even loved playing softball; she had a wickedly fast windmill pitch, having played throughout college and graduate school and on the law firm's recreational team." Do autotrophs need to carry out cellular respiration? Why or why not? Which geograhic feature made towns alongthe "fall line" prosper? *MountainsriversvalleysPlateaus The nervous system supports the body and protects internal organs true or false Fill in the blank with the Spanish word that best completes the sentence. Ella es de Japon. Ella es ____. Reflect on your reading of "A Modest Proposal" by Jonathon Swift, keeping in mind that this essay is biting irony written in the persona of a man representing the Commonwealth in a speech to Parliament. In Angela's Ashes, the narrator reads "A Modest Proposal" to Mr. Timoney, a man who is somewhat cynical of politics and religion.What is the significance of the young narrator's reading "A Modest Proposal"? How does Swift show the ruthless indifference of the English Commonwealth to the people of Ireland, and how are the Irish partially responsible for not improving the situation? Evaluate the following expressions.1. |2x + 7| + |1 - 2x^2| - 4x, given x = 3 Complete the chemical combustion reaction of naphthalene, whichdemonstrates the conservation of mass.C10H8 + 1202 >> The length of a rectangle is four times its width. If the perimeter of the rectangle is 80m , find its length and width. A different student is given a 10.0g sample labeled CaBr2 that may contain an inert (nonreacting) impurity. Identify a quantity from the results of laboratory analysis that the student could use to determine whether the sample was pure. How did the imperializing forces of Europe justify having more cargo? Question 5Ultraviolet (UV) radiation can damage DNA by breaking weak bonds. Which of the following best explains how this occurs?AUV radiation disrupts the double helix structure by breaking the covalent bonds between the nitrogenous base pairs,BUV radiation disrupts the double helix structure to breaking the hydrogen bonds between the nitrogenous base pairs.UV radiation is able to break DNA strands in two by breaking covalent bonds between the sugar phosphate backbone moleculesDUV radiation is able to break DNA strands in two by breaking hydrogen bonds between the sugar phosphate bachoone molecules A colony of ants carried away 12 of your4muffins. That was of all of them! How9many are left? You may turn right on a red light ONLY if you are in the right-most lane, you're turning into the right-most lane on the cross road, and _____. 1. What kind of person represented the ideal of the "Renaissance man"?a. someone who enjoyed worldly pleasuresb. someone who excelled in many areas of studyc. someone who specialized in a particular field of studyd. someone who supported and appreciated the arts without creating art