1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
# include <iostream>
# include <string>
# include <ctime>
# include <cctype>
using namespace std;
void menuDisplay();
void getLottoNum(int arr[], int size);
void genWinNums( int arr[], int size);
void checkMatches(int arr1[], int arr2[], int size);
void results(string name,int arr1[], int arr2[], int size);
bool isDuplicate(int arr[], int size, int numToCheck);
int main()
{
const int num = 7;
int userTicket[num], winningNums[num];
char choice;
string name1;
do
{
menuDisplay();
cin >> choice;
cout << endl;
if(choice == '1')
{
cout << "Please enter your name: ";
cin >> name1;
cout << endl;
getLottoNum(userTicket, num);
genWinNums(winningNums, num);
cout << endl;
results(name1,winningNums, userTicket, num);
}
else if(choice =='q'||choice =='Q')
{
cout << "You have chosen to quit the program" << endl;
}
else if(choice != '1' || choice != 'q' || choice != 'Q')
{
cout << "Invalid selection" << endl;
}
}while(choice != '1' || choice != 'q' || choice != 'Q');
system("PAUSE");
return 0;
}
void menuDisplay()
{
cout << "LITTLETON CITY LOTTO MODEL:" << endl;
cout << "---------------------------" << endl;
cout << "1) Play Lotto" << endl;
cout << "q) Quit Program" << endl;
cout << "Please make a selection: " ;
}
void getLottoNum(int arr[] , int size)
{
cout << "Please enter your 7 lotto number picks between 1 and 40." << endl;
for(int i = 0; i < size; i++)
{
do
{
cout << "Selection " << i+1 << ": ";
cin >> arr[i];
if(arr[i] < 1 || arr[i] > 40)
{
cout << "The number must be between 1 and 40. Please try again:" << endl;
}
}while(arr[i] < 1 || arr[i] > 40);
}
}
void genWinNums(int arr[], int size)
{
srand((unsigned int)time(NULL));
for(int i = 0 ; i < size ; i++)
{
arr[i] = rand() % 40 + 1;
}
}
void checkMatches(int arr1[], int arr2[], int size)
{
int match = 0;
for( int i = 0; i < size ; i ++)
{
}
}
void results(string name,int arr1[], int arr2[], int size)
{
cout << "" << name << "LOTTO RESULTS" << endl;
cout << "---------------------------" << endl;
cout << "WINNING TICKET NUMBERS: ";
for(int i = 0; i < size ; i++)
{
cout<<" "<< arr1[i] ;
}
cout << endl;
cout << "" << name << "'S TICKET: ";
for(int i = 0; i < size ;i++)
{
cout << " " << arr2[i] ;
}
cout << endl << endl;
cout << "RESULTS:" << endl;
cout << "--------" << endl;
cout << " Number Matches: " << endl;
cout << "Winnings : " << endl;
cout << endl;
}
bool isDuplicate(int arr[], int size, int numToCheck)
{
for(int i = 0;i<size;i++)
{
if(arr[i] = numToCheck)
{
return true;
}
}
return false;
}
|