Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//heres my code: been stuck on it for days now #include <iostream> #include <str

ID: 3643167 • Letter: #

Question

//heres my code: been stuck on it for days now

#include <iostream>
#include <string>
#include <cctype>
#include <ctime>
using namespace std;

int getLottoPicks( int num );
int GenWinNums( int num );
bool NoDuplicate(int);

int main()
{

const int num = 7;
int UserTicket[num];
int WinningNums[num];




char Selection;
string name;

do
{
cout << "LITTLETON CITY LOTTO MODEL: ";
cout << "--------------------------- ";
cout << "1) Play Lotto ";
cout << "q) Quit Program ";
cout << "Please make a selection: ";
cin >> Selection;

if(Selection == '1')
{
cout << "Please enter your name "; //users name
getline(cin, name);
cin.ignore();

getLottoPicks(num); // function for the users numbers

GenWinNums(WinningNums); // function for the random winning numbers from 1 to 40

//now i need to match the usernumbers and the users generating functions

//I am not sure how to display each statement depening
// on how many users numbers matched the winning numbers.


//JACKPOT - 1 MILLION if all 7 numbers were correct
//GREAT! - $100,000 if 6 numbers were correct
//LUCKY YOU! - $5,000 if 5 numbers were correct
/NOT BAD - $100 if 4 numbers were correct
/FREE TICKET if 3 numbers were correct
/SORRY NOTHING if 2 or less numbers were correct



}
else if(Selection == 'q')
{
cout << "You have quit the program ";
}

}while(Selection != 'q');

system("PAUSE");
return 0;
}

int getLottoPicks( int UserTicket[] ) //function for the users lotto numbers
{
const int num = 7;
int UserTicket[num] ;

for(int i = 0; i < num; i++)
{
cout << "Please enter your 7 lotto number picks ";
cin >> UserTicket[i];
cin.ignore();
}

return UserTicket[num];
}

int GenWinNums(int WinningNums[] ) //function for the winning numbers 1-40
{
srand ((unsigned int)time(NULL));

const int num = 7;


int WinningNums[num] ;

for(int i = 0; i< num; i++)
{

WinningNums[i] = rand() % 40 + 1;


}
return WinningNums[num];
}

bool NoDuplicates(int num) //this funtion is to check if there are duplicate numbers
{
const int num = 7;
int UserTicket[num];
int WinningNums[num];


for(int i = 0; i<num; i++)
{
for(int j =0; j< i; j++)
{
if (UserTicket[i] == UserTicket[j] || WinningNums[i] == WinningNums[j] )


return false;
}

return true;
}
}






Explanation / Answer

Hope this helps! **nums is defined twice in noDuplicates - Once in the parameter of the the function, so the compiler doesn't know which one you are talking about. **userTicket is defined twich in getLottoPicks - Once in the parameter of the the function , so the compiler doesn't know which one you are talking about. **WinningNum is defined twice in getWinNums - Once in the parameter of the the function , so the compiler doesn't know which one you are talking about. These lines all need to be commented out with double slashes. You only had one: NOT BAD - $100 if 4 numbers were correct FREE TICKET if 3 numbers were correct SORRY NOTHING The following functions declarations need to match their declarations(So their parameters have to be exactly the same in the declaration and definition): int getLottoPicks( int num ); int GenWinNums( int num[] ); bool NoDuplicate(int); #include #include #include #include using namespace std; int getLottoPicks( int num ); int GenWinNums( int num[] ); bool NoDuplicate(int); int main() { const int num = 7; int UserTicket[num]; int WinningNums[num]; char Selection; string name; do { cout