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

What term is used to describe an individual's money and personal property? budget income assets finances

Answers

Answer:

Pretty sure it's assests.

Explanation:

Income - Intake of money.

Budget - How much money you can spend.

Finances - Things you need to pay ort fund.

An asset is made up of the set of quantifiable goods and properties, which are owned by a person or a company.

What is an asset?

A right that has financial value is called an asset, which is a resource with value that someone owns.

Characteristics of an asset

The assets are recorded in the accounting balances, forming the credit.

The assets will receive a monetary value each, this valuation will depend on different criteria.

Therefore, we can conclude that the asset is the set of personal property, rights and other resources owned by a person.

Learn more about an asset here: https://brainly.com/question/16983188

What are three things to consider in programming design?
the problem being addressed, the goals of the project, and the programming language that will be used
the problem being addressed, the goals of the project, and the age of the end users
the age of the end users, the programming language that will be used, and the programming style of the
programmers working on the project
the age of the end users, the goals of the project, and the programming style of the programmers working on the
project

Answers

The issue being solved, the project's objectives, and the users' ages. The project's programmers' programming styles, the programming language they will use, and the age of the intended customers.

What is programming language?

Programming language is defined as a computer language used to converse with computers by programmers (developers). Orthogonality or simplicity, available control structures, data types, and data structures, syntactic design, support for abstraction, expressiveness, type equivalence, strong versus weak type checking, exception handling, and limited aliasing are among the characteristics of a programming language.

Clarity, simplicity, and unity offer a way to express algorithms as well as a framework for thinking about them. Every possible feature combination has value thanks to orthogonality. Surprisingly, it may frequently be reduced to three basic programming constructs known as loops, selects, and sequences.

Thus, the issue being solved, the project's objectives, and the users' ages. The project's programmers' programming styles, the programming language they will use, and the age of the intended customers.

To learn more about programming language, refer to the link below:

https://brainly.com/question/12696037

#SPJ5

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.

The __________ utility has the capability to manage users, create and administer user groups, and apply user rights to those users and groups. Active Directory Administrative Center Active Directory Domains and Trusts Active Directory Sites and Services Active Directory Users and Computers

Answers

Answer:

Active Directory Users and Computers

Explanation:

Active Directory Users and Computers is a term that describes Microsoft Management Console that is utilized in conducting and managing Active Directory, the objects; which comprises of the users and computers, the Organizational Units, together with their characteristics.

Hence, the Active Directory Users and Computers utility has the capability to manage users, create and administer user groups, and apply user rights to those users and groups.

true false) keybord has two shift keys.​

Answers

Answer:

True, looking at 'em right now!

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

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.

_______tools enable people to connect and exchange ideas.A) Affective computing. B) Social media. C) Debugging D) Computer forensics.

Answers

Answer:

B) Social media.

Explanation:

Social media is well, a media, that allows you to share things with people and have discussions.

How many pins are in the power supply connector that is typically used on most motherboards today?

Answers

Answer: 4 pins

Explanation:

Answer: 20+4 ATX pins.

Explanation: If you’re talking about supplying power from the PSU to the Motherboard then it would be the 20+4 pin connector. Back on old ATX motherboards it used to be the 20 pin connector.

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

Web pages are accessed through a software program called a _____.A) ​web crawlerB) ​web browserC) ​web serverD) ​web app drawer

Answers

Answer: B) ​web browser

Explanation: A web browser may be explained as a software program or application available on various operating systems such as windows, Mac, Android, iOS among others. This program acts as an interface between information available on websites or pages and users. This application takes a specified uniform resource locator or web address as input and outputs the information available on a web page. Google Chrome, Internet Explorer, Microsoft edge, opera mini, Safari, Firefox and so on.

The question is in the picture

Answers

Answer:

nordthaf

Explanation:

nofth

cellular digestion associated by what organelles?​

Answers

Answer:

lysosomes

Explanation:

Cell Digestion and the Secretory Pathway. The primary sites of intracellular digestion are organelles known as the lysosomes, which are membrane-bounded compartments containing a variety of hydrolytic enzymes.

It it associated with lysosomes

Why should we care about information being represented digitally? How does this impact you personally?

Answers

information digitally represented shows a level of understanding i.e it eases the stress of complexity. It is more interpretable.

it has a great impact on users personal since use can use and interpret information well as compared to other forms of represention

Reasons why the adoption of digital information representation should be made paramount include ; large storage, accessibility and retrieval among others.

Digital information may be explained to collection of records and data which are stored on computers and other electronic devices which makes use of digital storage components such as memory cards, hard drive and cloud services.

The advantages of digital data representation include :

Large storage space : Digital data representation allows large chunks of information to be kept and stored compared to traditional mode of data storage.

Easy accessibility : Digital information representation allows users to access and transfer data and stored information more easily and on the go as it is very easy to access and transfer information seamlessly to other digital devices.

Data stored digitally allows for easy manipulation and transformation of data as digital information allows for more orderly representation of information.

The personal impact of digital information from an individual perspective is the large expanse of storage it allows and ease of retrieval.

Learn more : https://brainly.com/question/14255662?referrer=searchResults

You’ve been given a new cell phone with a 2 gigabyte data plan. You plan to use your phone for text messages, images, video, and music. Which of these categories are best compressed using lossless compression? Which of these categories are best compressed using lossy compression? Why?

Answers

Answer:

texts and music are best compressed using lossy compression and videos are best compressed using lossless compression

Explanation: texts and music are best compressed using lossy compression because there are not many details to leave out while pictures and videos are best compressed using lossless compression because they need to be in good quality

Lossy compression should be applied to text messages and music while lossless compression should be applied to images and videos

A lossy compression of a file implies that the quality of the file is reduced in order to get the file compressed.

This type of compression can be applied to text messages and music because a reduction in the size and quality will only reduce few details about the text messages and music file.

However, a lossless compression is such that even after the file size is reduced, the quality remains unchanged. This type of compression can be applied to video and pictures because even if the size is reduced, the quality of the files are not expected to change.

Hence;

Lossy compression should be applied to text messages and musicLossless compression should be applied to images and videos

Read more about file compressions at:

https://brainly.com/question/13663721

Which color indicates the private, trusted segment of a network?
A. Green.
B. Orange.
C. Red.
D. Blue.

Answers

Answer:

A. Green.

Explanation:

In order to distinguish or represent different levels of networks, SmoothWall open source firewall solution, made use of three distinct colors to indicate different meanings. These are:

1. The red color is used to reveal that, there is no connection or network

2. Orange color reveals the untrusted segment of the network but shares the Internet connection

3. Green color indicates the private, trusted segment of a network

Hence, in this case, the correct answer is option A. Which is GREEN

When following maintenance procedures, it is important to carefully read the procedures and to complete
each step before moving to the next step.
True or
False

Answers

True, is the way to go

what are the earliest invention in human history​

Answers

Answer: Tools, Boats, Hand made bricks.

Explanation: The tools were the first technological advancement, the boats were the next, them hand made bricks for construction.

1605:newspapers
1608:telescope
1620:Compound microscope
1630:Slide rule
1642:mechanical calculator 1643:barometer
1650:vacuum pump
1656:pendulum clock

Hope this is enough

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!

Which of the following statement about device formatting is FALSE?
A) Device manufacturers store the initial file-system data structures in the device.
B) Operating system can create multiple partitions with in a single device.
C) Volume creation is implicit when a file system is placed directly within a partition.
D) Not every partition contains a copy of the operating systems.

Answers

Answer:

The correct option is;

A) Device manufacturers store the initial file-system data structures in the device.

Explanation:

Before a storage device can be used for data storage, it is required to prepare the device for use and to make the device to become visible to the operating system by formatting of the device

New storage devices are not pre-formatted or come with a ready to use file system as there are different file systems specifically designed for particular  operating systems or operating environment.

Formatting creates partitions, makes the hard drive visible to the operating system and creates a file system that is new such that the storage device can be used for storing files.

What does an output allow a computer to do

Answers

Output devices allow the computer system to interact with the outside world by moving data into and out of the system.

Answer:

the previous answer belowed me  looked it up online LOL

but im taking this quiz rn and the answer is either  Display information or Recieve information thanks bye

Explanation:

One of the simplest and best known polyalphabetic ciphers is _________ cipher. In this scheme, the set of related monoalphabetic substitution rules consists of the 26 Caesar ciphers with shifts of 0 through 25. Each cipher is denoted by a key letter which is the ciphertext letter that substitutes for the plaintext letter a.

Answers

Answer:

Vigenere

Explanation:

Vigenere Cipher is an encryption method of alphabetic symbols that utilizes an easy form of polyalphabetic exchange which is carried out through Vigenere table.

Hence, in this situation, the correct answer is VIGENERE Cipher because it is the form of cipher whereby the set of related monoalphabetic substitution rules comprises of the 26 Caesar ciphers with shifts of 0 through 25. Each cipher is indicated by a key letter which is the ciphertext letter that substitutes for the plaintext letter.

The parameter passing mechanisn used in C is

Answers

Answer:

Hope you understand this answer

Pass by value is the answer

What device to use when downloading a large file?

Answers

Pc is a device to downloading load file

How many different Microsoft Windows file types can be infected with a virus?

Answers

Phishing, scam, Fraud, just to get to hack your computer.

A stop sign is a example of:
A. An advertisement
B. An animated text
C. An audio text
D. A visual text

Answers

Answer:

A visual text

Explanation:

This is because it is used to send information through something you can see. Visual text is an image, word or picture that doesn't move used to share information. So because a stop sign can't move and it uses words to share information it is an example of a visual text.

HOPE IT HELPED  

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

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

paragraph on how atms work

Answers

ATM (Automatic Teller Machine) is a banking terminal that accepts deposits and dispenses cash. ATMs are activated by inserting cash (in cases of ATM Depositing) or debit /credit card that contain the user's account number and PIN on a magnetic stripe (for cash withdrawals)

Discuss the main characteristics of the database approach and how it differs from traditional file systems.

Answers

The database system allows the creation of a single depository of information, which is updated periodically and which can be used simultaneously by many users, since this type of system allows the effective sharing of all data stored in its depository . In addition, this is a secure system and is very difficult to break into. This is because of the efficiency of the software used to maintain it. However, the use of these softwares can be a little complicated for users, in addition to requiring a high economic cost to obtain them.

The traditional file system, in turn, each user must obtain their own file related to the application they want to run. This may seem dull in comparison to the database, but it is advantageous as it does not require any spending on software, as it is simple and there are several cheap and efficient tools and editors on the market. However, this system is not so safe, it can cause isolation of data and even data inconsistency, which disrupts the entire system.

Other Questions
a. {1, 2, 3, 4, 5} = {x | x E N and x < 5}True or False will give brainliest!! please help!!!*Note: The sample sentences in parentheses are just a guide to help you form your sentences. You must come up with your own original answers keeping academic integrity intact. What level (preschool, primary, secondary, etc.) of school do you go to? Make sure you use the yo form of the verb ir. (e.g., I go to _____ school.) i go to secondary Which statement best compares and contrasts lipids and carbohydrates?HURRY PLEASEE I HAVE TWO MINUTES JUST THE LETTER AWNSER Please help me!!!!! (25 points)Right answers only!!!!!! A equivalent ratio of 3:7 is? 3:96:109:12 What is the property of (4y + 1) x 0 =0 what is a hollow, muscular organ that pumps blood throughout the body. How do viruses spread globally? Provide at least 2 ways Do you think the study of Financial Accounting can help you in running your business? Why? Answer the questions with complete sentences based on the weather map. Answer the questions in Spanish. 1. Hace buen tiempo en Soria?2. Llueve en Teruel?3. Hace sol en Girona?4. Est nublado en Murcia?5. Nieva en Cceres?6. Qu tiempo hace en Salamanca?7. Hace viento cerca de Castelln?8. Qu tiempo hace en Almera?9. Est nublado en Las Palmas?10. Hace buen tiempo en Lleida? Read each question and choose the best answer. A graph shows a production possibilities curve. The horizontal axis is for watermelons in millions of tons and the vertical axis is for shoes in millions of pairs. The curve falls through the following points: (0, 15), (8, 14), (14, 12), (18, 9), (20, 5), and (21, 0). The point at (0, 15) is labeled Line b on the curve in the chart is referred to as A. the production-possibilities frontier B. the production-possibilities opportunity cost C. the resource plot point D. the resource prediction curve A scientist finds several hundred fish fossils in the dessert. This evidence best supports which of the following scientific ideas? 9 x 10' =______________________ 4(2x + 9) = - 17+ 13 milo runs 4.5 miles around his house he has to run 6.7 miles how many miles does he have to run left The typical dynastic cycle times are from 1600 B.C.E. to 1912 which of the following is the justification for overthrowing the previous ruling dynasty? - the Mandate of Heaven - natural disasters - a decrease in the quality of life -famine What was the African religious heritage of black Americans what were two groups that battled for power under the republic why do chinese maps show the pacific ocean at the center? The city name Huaycan comes from the _language.The architecture in Cartagena, Colombia can be described asThe city of Cartagena is famous for itsHow are the volunteering opportunities in the United States similar to the opportunities in someSpanish-speaking countries?