Lottery Game App

Create a lottery game application. Generate ten (10) sets, with each set has 6 random numbers and each number is between 1 and 62.
Requirements:
(1) You need to have a loop that runs 10 times, each time generate 6 random numbers.
(2) You need to use arrays to store the 6 numbers generated.
(3) Each set generates no repeating numbers.
(4) Display you result, with numbers in each set is shown in ascending order.

*I have been messing around with this code my professor helped me build but i cant seem to untangle some of the functions to create what he wants in the assignment above*

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
 const int MAX_VAL = 53;
const int NUM_NUMS = 6;
const int MAX_ROWS = 10;

void quickPick(int row[NUM_NUMS]);
void displayTicket(int ticket[MAX_ROWS][NUM_NUMS], int rows);
void sortRow(int row[NUM_NUMS]);

// Save as Main.cpp

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>

using namespace std;
unsigned seed = time(0);
void quickPick(int row[NUM_NUMS])
{
   bool used[MAX_VAL + 1];
   int pick;
  
   //Reset the used array;
   for(int i=1; i<=MAX_VAL; i++)
   used[i] = false;
  
   //Pick the numbers;
   for(int i=0; i<NUM_NUMS; i++)
   {
       do
       {
           pick = rand() % MAX_VAL + 1;
       }while( used[pick]);
      
       row[i] = pick;
       used[pick] = true;
   }
}

void sortRow(int row[NUM_NUMS])
{
    for(int k=0; k<NUM_NUMS; k++)
   {
        int min = k;      
       for(int j=k+1; j<NUM_NUMS; j++){
           if(row[j] < row[min])
           min = j;
       }
       int temp = row[k];
       row[k] = row[min];
       row[min] = temp;
   }
}
void displayTicket(int ticket[MAX_ROWS][NUM_NUMS], int rows)
{
   cout << endl << endl << endl << endl << endl;
   cout <<"   LOTTERY TICKET"<<endl;
   cout <<"   ---------------------------"<<endl;
   cout <<"   Ticket No. " << seed<< endl;
   cout <<"   ---------------------------"<<endl;
  
   for(int i=0; i<rows; i++)
   {
       for(int j=0; j<NUM_NUMS; j++)
           cout << setw(5)<< ticket[i][j];
       cout << endl;
   }
}

int getDraws(int MIN , int MAX)
{
   int number_of_draws;
   cout <<"   Enter number of draws: ";
   cin >> number_of_draws;
   cout << endl;
  
   while(number_of_draws <=MIN || number_of_draws > MAX)
   {
        if(number_of_draws == 0) return 0;
       cout <<"   Number of draws must be from "<< MIN+1 << " to " << MAX << endl;
       cout <<"   Enter number of draws: ";
       cin >> number_of_draws;      
       cout << endl;
   }
  
   return number_of_draws;
}

int main()
{
   int ticket[MAX_ROWS][NUM_NUMS];
   int numDraws;
  
   srand(seed);
   numDraws = getDraws(0, MAX_ROWS);

   if(numDraws == 0)
   {
       cout<<"   Cancelling the Transaction\n\n";
       return 0;
   }
  
   for(int i=0; i<numDraws; i++)
   {
       quickPick(ticket[i]);
       sortRow(ticket[i]);
   }
  
   displayTicket(ticket, numDraws);
   return 0;
}
What is the problem ?
Why the input ? The assignment says 10 sets.

Enter number of draws: 10






   LOTTERY TICKET
   ---------------------------
   Ticket No. 1524813173
   ---------------------------
   24   26   31   41   42   49
   16   23   31   37   41   47
    8   13   17   30   44   46
   11   13   20   24   43   45
   10   24   37   44   46   48
    2   25   38   43   44   53
    5    6   11   13   15   21
    2   19   25   28   30   49
    5   10   12   17   18   48
    2   11   12   20   44   45


You got 10 set sorted with unique numbers between 1-62. What else do you want ?
Topic archived. No new replies allowed.