//Devin Scheu CS1A Chapter 8, P. 487, #2
//
/**************************************************************
*
* CHECK LOTTERY WINNER
* ____________________________________________________________
* This program determines if the user's winning number matches
* any of the player's lucky combinations.
* ____________________________________________________________
* INPUT
* winningNumber : The 5-digit winning number entered by the user
*
* OUTPUT
* winStatus : Message indicating if the number is a winner or not
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
//Variable Declarations
const int NUM_TICKETS = 10; //OUTPUT - Number of tickets
long luckyNumbers[NUM_TICKETS] = {13579, 26791, 26792, 33445, 55555,
62483, 77777, 79422, 85647, 93121};
long winningNumber; //INPUT - The 5-digit winning number entered by the user
bool isWinner = false; //PROCESSING - Flag indicating if the number is a winner
string winStatus; //OUTPUT - Message indicating if the number is a winner or not
//Prompt for Input
cout << "Enter this week's 5-digit winning number: ";
cin >> winningNumber;
cout << winningNumber << endl;
//Linear Search for Match
for (int i = 0; i < NUM_TICKETS; i++) {
if (luckyNumbers[i] == winningNumber) {
isWinner = true;
break;
}
}
winStatus = isWinner ? "You have a winning ticket!" : "No winning ticket this week.";
//Separator and Output Section
cout << "-------------------------------------------------------" << endl;
cout << "OUTPUT:" << endl;
//Output Result
cout << left << setw(25) << "Win Status:" << right << setw(15) << winStatus << endl;
} //end of main()