Question: Hello, I need a pseudocode and a flowchart for this code #include #include #include using namespace std; void startingMessge(); void userNumberspick(string); void selectionSort(int [],int); void

Hello, I need a pseudocode and a flowchart for this code

#include

#include

#include

using namespace std;

void startingMessge();

void userNumberspick(string);

void selectionSort(int [],int);

void swap(int *,int *);

int randomNumberGenrator(int,int );

void endingMessage();

void printArray(int []);

void genrateWinningNumbers();

int userNumber[6],winnigNumbers[6];

int main()

{

int i,j,powerBall;

startingMessge();

char choice;

while(true)

{

cout<<"Do you want to self pick your white ball numbers (Y or N): ";

cin>>choice;

if(choice=='Y')

{

userNumberspick("self_pick");

break;

}

if(choice=='N')

{

userNumberspick("auto_pick");

break;

}

}

while(true)

{

cout<<"Do you want to self pick your red ball numbers (Y or N): ";

cin>>choice;

if(choice=='Y')

{

cout<<"Enter power ball number (between 1 and 26):";

cin>>powerBall;

break;

}

if(choice=='N')

{

powerBall=randomNumberGenrator(1,26);

break;

}

}

userNumber[5]=powerBall;

genrateWinningNumbers();

int wonPoints=0,matchWhiteBalls=0;

for(i=0;i<5;i++)

{

for(j=0;j<5;j++)

{

if(userNumber[i]==winnigNumbers[i])

matchWhiteBalls++;

}

}

if( winnigNumbers[5]==powerBall || (matchWhiteBalls==1 && winnigNumbers[5]==powerBall) )

wonPoints=4;

else if( (winnigNumbers[5]==powerBall && matchWhiteBalls==2) || (matchWhiteBalls==3) )

wonPoints=7;

else if( (winnigNumbers[5]==powerBall && matchWhiteBalls==3) || (matchWhiteBalls==4) )

wonPoints=100;

else if( (winnigNumbers[5]==powerBall && matchWhiteBalls==4) )

wonPoints=50000;

else if(matchWhiteBalls==5)

wonPoints=1000000;

else if(winnigNumbers[5]==powerBall && matchWhiteBalls==5)

wonPoints=1000000000;

else

wonPoints=0;

cout<<" ********** Game Report ********** "<

cout<<"You won "<

cout<<"Here are your numbers"<

printArray(userNumber);

cout<<" Here are Winning numbers"<

printArray(winnigNumbers);

endingMessage();

return 0;

}

void genrateWinningNumbers()

{

for(int i=0;i<6;i++)

{

winnigNumbers[i]=randomNumberGenrator(1,69);

}

}

void endingMessage()

{

cout<<" ** NOTE: The last number is Power Ball Number!! **"<

cout<<"********************************"<

cout<<"Thank you for usign my program!!"<

cout<<"Programmer: Tina Lee"<

cout<<"CMSC140 common project 5"<

cout<<"Due Date: 12/1/2018"<

}

void printArray(int arr[])

{

for(int i=0;i<6;i++)

{

cout<

}

}

void startingMessge()

{

cout<<"Number Guessing Game"<

cout<<"----------------------"<

cout<<"1. Select FIVE numbers from 1 to 69 for the white balls."<

cout<<"1. Select ONE numbers from 1 to 26 for the red Powerballs."<

cout<<"1. Proize Determine by how manu of your number match the winning numbers."<

}

void userNumberspick(string mode)

{

int number;

if(mode=="self_pick")

{

for(int i=0;i<5;i++)

{

while(true)

{

cout<<"Enter number "<<(i+1)<<" (between 1 and 69):";

cin>>number;

if(number>=1 && number<=69)

break;

}

userNumber[i]=number;

}

}

else

{

for(int i=0;i<5;i++)

{

userNumber[i]=randomNumberGenrator(1,69);

}

}

selectionSort(userNumber,5);

}

int randomNumberGenrator(int min,int max)

{

int range = max - min + 1;

int num = rand() % range + min;

return num;

}

void swap(int *xp, int *yp)

{

int temp = *xp;

*xp = *yp;

*yp = temp;

}

void selectionSort(int arr[], int n)

{

int i, j, min_idx;

// One by one move boundary of unsorted subarray

for (i = 0; i < n-1; i++)

{

// Find the minimum element in unsorted array

min_idx = i;

for (j = i+1; j < n; j++)

if (arr[j] < arr[min_idx])

min_idx = j;

// Swap the found minimum element with the first element

swap(&arr[min_idx], &arr[i]);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!