Menu

[solved]-Good Day Program Emulate Powerball Mistakes Cannot Trace C Program Would Appreciate Possib Q39037578

Good day, I have a program to emulate the PowerBall but I havesome mistakes that I cannot trace, this is a c++ program. I wouldappreciate if it is possible to give me pointers on the best way towrite this program from what I have done so far. It is not perfectbut I want to get more knowledge on the best ways to writeprograms. I also have the requirements below.

Program is below. Any suggestion would be fine too. Thankyou.

#include <iostream>
#include <string>
#include<time.h>
#include<cstdlib>
#include<ctype.h>

using namespace std;
int RandomNumbers[6];

int winningNumbers[6];

int UserPicks[6];

char UserChoice;

void welcomemessage();

void choice();

int autoLottery(int min, int max);

void selectionSort(int arr[], int n);

void generateWinningNumbers(int winningNumbers[]);

void endingMessage();

void printArray(int arr[]);

int userNumbers(int userPicks[]);

void displayResults(int userNumbers[], intwinningNumbers[]);

void endingMessage();

int main() {

   welcomemessage(); //Call the welcomemessagefunction
   choice(); //Call the choice function
   if (UserChoice == ‘A’ || UserChoice == ‘a’) {
       autoLottery(1, 69); //callsautoLottery function
   }
   else
       userNumbers(UserPicks);
      
   displayResults(userNum, winningNumbers);

   system(“pause”);
   return 0;
}

void welcomemessage() {
   cout << ” POWERBALL LOTTERYn”;
   cout << “Welcome to the PowerBall LotteryGamen”;
   cout << “Read the Rules beforePlaying:n”;
   cout << “1. Select your game mode: Auoto-Pick orSelf-Pickn”;
   cout << “2. Randomize input 5 White Ball numberbetween 1 to 69n”;
   cout << “3. Randomize input 1 Red PowerBallnumber between 1 to 26n”;
   cout << “4. See which number match! Will you getthe GRAND PRICE of $999 MILLIONnnn”;
}

int autoLottery(int min, int max)
{
  

       srand(time(0));
       int range = max – min + 1;
       int num = rand() % range + min;

       return num;
  
}
void choice() {
   // Stores the User choice
   cout << “Enter a choice: n”;
   cout << “A. Auto-Pick (Randomly GeneratedNumbers)n”;
   cout << “B. Self-Pick (You Pick YourOwn)n”;
   cin >> UserChoice;
   while ((UserChoice != ‘A’) && (UserChoice !=’B’) && (UserChoice != ‘a’) && (UserChoice != ‘b’)){
       cout << “INVALID CHOICE. TRYAGAIN.n”;
       cout << “A. Auto-Pick(Randomly Generated Numbers)n”;
       cout << “B. Self-Pick (YouPick Your Own)n”;
       cin >> UserChoice;
   }
  
}

int userNumbersWhite(int userPicks[]) {
   cout << “Enter FIVE White lottery numbersn”;
   for (int num = 0; num < 5; num++) {
       cin >> UserPicks[num];

       while (UserPicks[num] < 1 ||UserPicks[num] > 69) {
           cout <<“INVALID CHOICE. TRY AGAIN.n”;
           cout <<“Please Enter Number from 1 to 69n”;
           cin >>UserPicks[num];

           returnUserPicks[num];
       }

   }
  
}
int UserNumberRed() {
   int num = 0;
   cout << “Enter ONE Red lottery numbersn”;
   cin >> UserPicks[num];
   if (UserPicks[num] < 1 || UserPicks[num] >26)
       return UserPicks[num];
}

void swap(int *ab, int *cd)
{
   int temp = *ab;
   *ab = *cd;
   *cd = temp;
}
void selectionSort(int arr[], int n)
{
   int i, j, min_idx;

   // One by one move boundary of unsortedsubarray
   for (i = 0; i < n – 1; i++)
   {
       // Find the minimum element inunsorted array
       min_idx = i;
       for (j = i + 1; j < n;j++)
           if (arr[j] <arr[min_idx])
              min_idx = j;

       // Swap the found minimumelement with the first element
       swap(&arr[min_idx],&arr[i]);
   }
}
void generateWinningNumbers(int winningNumbers[])
{
   int max = 69;
   for (int i = 0; i < 6; i++)
   {
       // Powerball is the sixth elementand cannot be greater than 26.
       max = i < 5 ? 69 : 26;
       winningNumbers[i] = autoLottery(1,max);
   }
}
void displayResults(int userNum[], int winningNumbers[])
{
   cout << “nn********** Game Report**********n” << endl;
  
   cout << “Here are Your numbers:” <<endl;
   printArray(userNum);
   cout << “nnHere are the Winning numbers:”<< endl;
   printArray(winningNumbers);
   endingMessage();
}
void printArray(int arr[])
{
   for (int i = 0; i < 6; i++)
   {
       cout << arr[i] << “”;
   }
}
void endingMessage()
{
   string choice;

   cout << “nn** NOTE: The last number is thePower Ball Number!! **” << endl << endl;
   cout << “********************************”<< endl << endl;
   cout << “Thank you for using my program!!”<< endl;
   cout << “Programmer: Joshua Elubiaozor” <<endl;
   cout << “CMSC140 common project 5 POWERBALL”<< endl;
   cout << “Due Date: 7/14/2019” << endl<< endl;
  
}

AutoSave Of 140-Project 5(100 pts) - PawerPlay (Extra Credit Elub aczor, Chinedlum J X Read Only Saved to this PC Share Refer

AutoSave Of 140-Project 5(100 pts) – PawerPlay (Extra Credit Elub aczor, Chinedlum J X Read Only Saved to this PC Share References Mailings Hе р Tell me what you want to do Fils Home Insert Draw Design Layout Review View Find Cut A Aa dalb Calla AaBbC AaBbcc AabCeDAaBbCcD AaBbCcT Cambria 13 A a Replace Capy T Nermal Emphasis 1 Heading 1 1Heading 2 Paste Subtitle A- aly- A Strong х? в U abc Х2 Select Format Painter Cipbaard Fant Paragraph Styles Editing .4 2 5 1 I 1. 3 мSC: ми 1NTксо та PRснRANм NE MS: 00INUD IO PROURAMMINE Project 5/Power Ball Input Ticket chnice self.pick or auto.pick This project is worth 100 points. .For selfpick tickets beiween 1 ad 69 (wile balls) One numher between and 26 (ped hall) Fowerball is a lollery gae and i’s available in may sU.S.) Stales Visi www.powerall.cuаекроwertull te lт пот aboоul he sae, is rules and Bries r aulo ge rd halls are gesecaled by the copulen .Ier validations. Пете Select ive auabers between 1 and 59 lo tbe wule balls; dheu aelect oue auuibe Qutput li 26 er he red Powerball .(ane titla cald win a prizot Gaie tle Fch tieket (5 white halls +I red ball) can he () user selected (2) randomly tincluding Ga generaled (by he compuler syslem) Prize wever, use thea as guidauce ouly your eauirements are differeut) Sorted wirning cambers See sample mes (however, yours will be differcnt) Requirements/ Approach Extra Credit Opportunity (Up to 10% of Project Grade) sign, imnlemenr and test a -pogram which will sinulara the lottery onmo For this praiect, consider the (nay out of the) Grund Prize as US $999 000 000 Addilional pararaph(s) MUST BE included in your wrile-up lo clearly arliculale Your pragam will need to ei l th di oaor Wll ave the ial saviag-as lat as the Jevel 6 pumbers: or allow usar to select mumbers for ench urchased ticket Algorithm. Pseudocode & Flowcha . oschan and algorithm for this project deletie eprize depending n lw yubers are guessed corectly single ttmue-is te foc ore thau 100 ckets (at auy nn’t forgt, cach drwing noeds to be urique. The pohahility having the exact same winning numbers is exirenely w (apprximalely 0%%) Fach studert ruust complete (ard bit th t two drmwings .come tenics Functions and their repective aratatynes mast he specified and utilined. For exnmple d roum lottery mumber acconding ro the Fuactous tion andomly genorar mle ithm Sonine aleurith Implement additional funcrions as needed A projoct will cam at mosn et e t ardet thi is the case Academic Honesty Policy Reminder – ill be comnaed avainst other submissinns frm current and nreviousemesters rom work-ach mbmimed praject vo Page 1 of 5 859 улагds 7:58 PM O Type here to search AD 7/13/2019 Show transcribed image text AutoSave Of 140-Project 5(100 pts) – PawerPlay (Extra Credit Elub aczor, Chinedlum J X Read Only Saved to this PC Share References Mailings Hе р Tell me what you want to do Fils Home Insert Draw Design Layout Review View Find Cut A Aa dalb Calla AaBbC AaBbcc AabCeDAaBbCcD AaBbCcT Cambria 13 A a Replace Capy T Nermal Emphasis 1 Heading 1 1Heading 2 Paste Subtitle A- aly- A Strong х? в U abc Х2 Select Format Painter Cipbaard Fant Paragraph Styles Editing .4 2 5 1 I 1. 3 мSC: ми 1NTксо та PRснRANм NE MS: 00INUD IO PROURAMMINE Project 5/Power Ball Input Ticket chnice self.pick or auto.pick This project is worth 100 points. .For selfpick tickets beiween 1 ad 69 (wile balls) One numher between and 26 (ped hall) Fowerball is a lollery gae and i’s available in may sU.S.) Stales Visi www.powerall.cuаекроwertull te lт пот aboоul he sae, is rules and Bries r aulo ge rd halls are gesecaled by the copulen .Ier validations. Пете Select ive auabers between 1 and 59 lo tbe wule balls; dheu aelect oue auuibe Qutput li 26 er he red Powerball .(ane titla cald win a prizot Gaie tle Fch tieket (5 white halls +I red ball) can he () user selected (2) randomly tincluding Ga generaled (by he compuler syslem) Prize wever, use thea as guidauce ouly your eauirements are differeut) Sorted wirning cambers See sample mes (however, yours will be differcnt) Requirements/ Approach Extra Credit Opportunity (Up to 10% of Project Grade) sign, imnlemenr and test a -pogram which will sinulara the lottery onmo For this praiect, consider the (nay out of the) Grund Prize as US $999 000 000 Addilional pararaph(s) MUST BE included in your wrile-up lo clearly arliculale Your pragam will need to ei l th di oaor Wll ave the ial saviag-as lat as the Jevel 6 pumbers: or allow usar to select mumbers for ench urchased ticket Algorithm. Pseudocode & Flowcha . oschan and algorithm for this project deletie eprize depending n lw yubers are guessed corectly single ttmue-is te foc ore thau 100 ckets (at auy nn’t forgt, cach drwing noeds to be urique. The pohahility having the exact same winning numbers is exirenely w (apprximalely 0%%) Fach studert ruust complete (ard bit th t two drmwings .come tenics Functions and their repective aratatynes mast he specified and utilined. For exnmple d roum lottery mumber acconding ro the Fuactous tion andomly genorar mle ithm Sonine aleurith Implement additional funcrions as needed A projoct will cam at mosn et e t ardet thi is the case Academic Honesty Policy Reminder – ill be comnaed avainst other submissinns frm current and nreviousemesters rom work-ach mbmimed praject vo Page 1 of 5 859 улагds 7:58 PM O Type here to search AD 7/13/2019

Expert Answer


Answer to Good day, I have a program to emulate the PowerBall but I have some mistakes that I cannot trace, this is a c++ program…. . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *