Question

In: Computer Science

8.2: Lottery Winners A lottery ticket buyer purchases 10 tickets a week, always playing the same...

8.2: Lottery Winners A lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5-digit “lucky” combinations. Write a program that initializes an array or a vector with these numbers and then lets the player enter this week’s winning 5-digit number. The program should perform a linear search through the list of the player’s numbers and report whether or not one of the tickets is a winner this week. Here are the numbers: 13579 26791 26792 33445 55555 62483 77777 79422 85647 93121

#include <iostream>
using namespace std;
int main(){
int numbers[10]={13579,26791,26792,33445,55555,62483,77777,79422,85647,93121};
int i,win=-1, n;
cout << endl << "Enter this week's 5-digit winning lottery number:";
cin>>n;
for(i=0;i<10;i++)
if(n==numbers[i])
{
cout <<" You have a winning ticket.\n";win=i;
}
if(win<0)
cout<<"You did not win this week.\n" << endl;

return 0;
}

you displayed:
...
Enter this week's 5-digit winning lottery number:You did not win this week.

instead of:
Enter this week's 5-digit winning lottery number:You did not win this week.

I'm not sure what I have wrong

Solutions

Expert Solution

your code is absolutely correct there is no error .

look up i have added the screenshot


Related Solutions

Jack and Diane are lottery winners. They hold the ticket to the Grand Prize in the...
Jack and Diane are lottery winners. They hold the ticket to the Grand Prize in the “Set for Life” Prize that makes 20 consecutive annual payments of $50,000 starting immediately. There is one hitch: the eleventh payment (to be received at the end of year 10) is not $50,000 but only $20,000 (that is, this payment is $30,000 LESS than the other 20). Which of the following comes closest to the present value of the prize if interest rates are...
1) You buy a lottery ticket to a lottery that costs $10 per ticket. There are...
1) You buy a lottery ticket to a lottery that costs $10 per ticket. There are only 100 tickets available to be sold in this lottery. In this lottery there are one $500 prize, two $100 prizes, and four $25 prizes. Show its probability distribution in the form of a table. What is the standard deviation of your gain or loss? What type of skewness does the probability distribution represent?
Fiji tattslotto sells a lottery ticket for two dollars. Out of 10,000 tickets printed for this...
Fiji tattslotto sells a lottery ticket for two dollars. Out of 10,000 tickets printed for this lottery, 1 ticket has a price of five thousand dollars, 5 tickets have a price of one thousand dollars each, 100 tickets have a price of $10 each and 1000 tickets contain a price of five dollar each. Let X be the r.v. that denotes the net amount a player wins in this lottery. a write the probability of distribution of X. b.Determine the...
Assume that 25-year-old Denise wastes $10 per week buying lottery tickets, averaging $520 per year. Now...
Assume that 25-year-old Denise wastes $10 per week buying lottery tickets, averaging $520 per year. Now let's assume that Denise "sees the light" and decides to take that $520 she would have spent on lottery tickets and deposit it at the end of each year in an annuity paying 6% compounded annually. By now, Denise is 45 years old. She's got a pretty good job, but she's starting to think about retirement and realizing that Social Security just isn't enough...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5;...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5; $10, .5); l3 = ($55, 1); l4 = ($110, .5; $0, .5); l5 = ($100, .7; $10, .3). (a) If you know that an individual is an expected utility maximizer (who likes money), but you do not know more about this person, what can you say about how this individual ranks the lotteries? (You should conclude that one/some comparison(s) are unclear, but one/some can...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5;...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5; $10, .5); l3 = ($55, 1); l4 = ($110, .5; $0, .5); l5 = ($100, .7; $10, .3). Refer to the list of lotteries in the question above. Draw two coordinate diagrams where one could draw some of those two-outcome lotteries when we consider fixed probabilities and varying prizes. In one diagram you can draw all but one of the lotteries, in the other...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5;...
Consider the following five lottery tickets: l1 = ($100, .5; $10, .5); l2 = ($110, .5; $10, .5); l3 = ($55, 1); l4 = ($110, .5; $0, .5); l5 = ($100, .7; $10, .3). Refer to the list of lotteries in the question above. Draw two coordinate diagrams where one could draw some of those two-outcome lotteries when we consider fixed probabilities and varying prizes. In one diagram you can draw all but one of the lotteries, in the other...
The boy’s buyer purchases 10 dozen pairs of shorts at $180 per dozen, and 5 dozen...
The boy’s buyer purchases 10 dozen pairs of shorts at $180 per dozen, and 5 dozen tank tops at $72 per dozen.  The target markup for the department is planned at 52%. If the shorts are priced at $32 each, what retail price must be placed on the tank tops in order to achieve the target markup goal? The answer is $11.00 I just don't know how to get there.
Week 10 Fujitsu Ltd purchases inventory from DFO Ltd, a listed British company. Relevant events and...
Week 10 Fujitsu Ltd purchases inventory from DFO Ltd, a listed British company. Relevant events and the spot rates at each date are shown as follows: Date Event Spot rate 15 March 2019 Order £300,000 of inventory A$1.00 = £0.37 11 May 2019 Purchase takes place as inventory shipped to Fujitsu Ltd (FOB) A$1.00 = £0.41 30 June 2019 End of financial year A$1.00 = £0.43 02 July 2019 Inventory arrives at warehouse A$1.00 = £0.42 14 August 2019 Payment...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT