//Cecilia Rangel CSC5 Chapter 7, P.447, #13
//
/**************************************************************
*
* LOTTERY APPLICATION
* ____________________________________________________________
* This program will randomly generate 5 number between 1 and 9 in
* an array for a lottery ticket.
*
*_____________________________________________________________
* INPUT
* user[SIZE] : INPUT the 5 digits of the user.
*
* OUTPUT
* lottery[SIZE] : OUTPUT the 5 digits of the lottery(randomnize)
* ***************************************************************/
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
//Making variables
const int SIZE = 5;
int lottery[SIZE];
int user[SIZE];
//count to input arrays
int count = 0;
//bool value to check for matching digit
bool match = true;
//Input the 5 digits of your lottery
cout << "Enter your 5 digit of your lottery: ";
for(count = 0; count < SIZE; count ++)
{
cin >> user[count];
}
//Randomize the lottery number
srand( time(0));
for(count = 0; count < SIZE; count ++)
{
lottery[count] =rand()% 9 + 0;
}
//OUTPUT the 5 digits of user's numbers
for(count = 0; count < SIZE; count ++)
{
cout << user[count] << " ";
}
//OUTPUT the 5 numbers of the randomize numbers
cout << endl;
cout << left;
cout << setw(36) << "Lottery's winning numbers: ";
for(count = 0; count < SIZE; count ++)
{
cout << lottery[count] << " ";
}
//Checking for matching digits
int total = 0;
for(count = 0; count < SIZE; count ++)
{
if (user[count] != lottery[count])
{
match = false;
}
else
total += 1;
}
//OUTPUT the matching digits
cout << setw(37) << "\nThe amount of digits matched: " << total<< endl;
//Winning 5 Million Dollars if you got all 5 digits matched
if (total == 5)
cout << "Congratulation! you've won 5 Million Dollars!!!!!!\n";
return 0;
}