
//Dione Torrevillas                 CS1A                 Chapter 8, P. 487, #2

/**********************************************************
 * Class: CS1A
 * Chapter 8 Homework - Programming Challenge #2
 * Title: Lottery Winners
 *
 * Description:
 * This program uses linear search to check whether one of
 * the player's ticket numbers matches the winning number.
 *
 * INPUT:
 * This week's winning five-digit lottery number.
 *
 * OUTPUT:
 * A message saying whether a ticket is a winner.
 **********************************************************/

#include <iostream>
using namespace std;

int main()
{
    const int SIZE = 10;
    const int tickets[SIZE] = {
        13579, 26791, 26792, 33445, 55555,
        62483, 77777, 79422, 85647, 93121
    };

    int winningNumber;  //INPUT - Winning lottery number
    bool winner = false;

    cout << "Enter this week's winning five-digit number: ";
    cin >> winningNumber;

    // Search the tickets one at a time using linear search.
    for (int i = 0; i < SIZE; i++)
    {
        if (tickets[i] == winningNumber)
        {
            winner = true;
            break;
        }
    }

    //OUTPUT - Display whether a ticket matched.
    if (winner)
        cout << "Congratulations! You have a winning ticket." << endl;
    else
        cout << "None of your tickets won this week." << endl;

    return 0;
}
