NEED TO PROGRAM THIS IN C FORMAT NO JAVA A lottery ticket bu

NEED TO PROGRAM THIS IN C++ FORMAT. NO JAVA

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 with these numbers and then lets the player enter this week’s winning 5-digit number. The program should perform a sequential 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:

13543   12451 23443   18543   25623   33555 11221 44222 77777   93121

Solution

The C++ program for the lottery ticket is:

#include <iostream>

using namespace ltrytckt;

int searchList(int [], int, int);

int main()

{

const int NUMS = 10;

int Picks[NUMS] = {13543 , 12451 , 23443 , 18543 , 25623 , 33555, 11221, 44222 , 77777 , 93121};

int WinNums,                    // This is used for winning numbers

Search;                                 // It is for holding the search results

// Please enter a 5 digit number

cout << \"Enter this week’s winning 5 digit number: \";

cin >> WinNums;

Search = searchList(Picks, NUMS, WinNums);

if (Search == -1)

cout << \"Sorry, no winning ticket this week.\ \";

else

{

cout << \"Congratulations!\ You have the winning five-digit number: \"

                                                << Picks[Search] << endl;

}

return 0;

}

int searchList(int list[], int size, int value)

{

int index = 0;                                     

int position = -1;                              

bool found = false;                         

while (index < size && !found)

{

if (list[index] == value)

{

position = index;                             

found = true;                                     // Set flag

}

index++;                                                                              // which goes to next element

}

return position;                                                // it return the position, or -1

}

NEED TO PROGRAM THIS IN C++ FORMAT. NO JAVA A lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5-digit “lucky” combinations. Write a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site