Need help with generating random number of people

closed account (i8bjz8AR)
I need help with generating a random number of pirates that will be voting on 10 laws. I have used rand and srand to generate random numbers that each pirate will be uniquely assigned to, used to vote, but now i need to assign these random numbers to a random number of pirates. Each pirate may or may not vote every time either, that being "yes" or "no" for two candidates. Can anybody help me out? Thanks!

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
  #include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

int main()
{
        int uniqueNumber;
        srand( time(0)); // This will ensure a really randomized number by help of time.

        uniqueNumber=rand()%50+4; // Randomizing the number between 4-50.
        cout << "Shows a random number: " << uniqueNumber << endl;



        string NameOfCanidate;
        //voting process, two choices for the pirates
        cout << "Please decide who you will be voting for, the captain or the new guy: " << endl;
        cin >> NameOfCanidate;


        cout << "Below is a list of the 10 amendments that the two pirates will vote on \naccording to the ships constitution" << endl;
        int amendments = 0;
        cin >> amendments;    // selecting the amendment
        switch (amendments){  // for outputting the amendment(s) voted on, which will
                              // be passed on to a function in main to call


    case 1: cout << "What does the fox say? Whatever WE tell it to";  //case 1-10 are the 10 amendments to be voted on
            break;
    case 2: cout << "From now on the annual Cinco De Mayo party will be held on March 8th ";
            break;
    case 3: cout << "Beginning this year, sharks shall have a week dedicated to us";
            break;
    case 4: cout << "Pirates are now allowed to talk about fight club";
            break;
    case 5: cout << "When in Rome, the Romans will do as WE do.";
            break;
    case 6: cout << "Our mothers will immediately get tattoos that say SON";
            break;
    case 7: cout << "From now on the President will take our birthdays off.";
            break;
    case 8: cout << "If we say something costs an arm and a leg, it does";
            break;
    case 9: cout << "Freemasons are ordered to learn OUR secret handshake.";
            break;
    case 10: cout << "If a tree falls in the forest and no one is around, it will make a sound only with our permission ";
            break;
    default: cout << "This won't be used since a amendment will always be voted on, thus never be shown or checked I believe.. (Please correct me) ";
            break;

        }






    }

   //     void constitution // the function that will call my amendments in my main function
                          // how will i create this will 10 possible amendments to choose from?
                          // There are 4 pirates and they will vote either yes or no,
Topic archived. No new replies allowed.