Stuck on Project "Pirate Election"

Hey guys, I am supposed to write a program that uses different functions to accomplish a main task. Below is the task assigned for better understanding

---------------------------------------------------------------------------------Your task is three-fold. First, as you read in the ballots, create parallel arrays full of all of the ballot file’s ballots, but that keeps or contains only those ballots that were used in the count, and not the duplicates. Remember that will be the first vote you encounter in the data for each pirate. You will also need to keep track of all of the “cheat” votes, those that were duplicates or triplicates or … You will not need to store those in any form except to accumulate a total of them.

Next, you will need to create a new file (counted.txt) and simply write out your good ballots from your arrays into this file. It will end up looking like the original ballot.txt, less those duplicated votes that you did not put into your arrays.

Finally, determine the results of the election and print them out on the screen. Your output should include:

The candidate name list and how many votes each received.

How many total votes were cast. (This includes the cheat ballots.)

How many actual pirates voted.

If each issue passed or failed and the number of yes votes it received.

Who the new captain and first mate are.
--------------------------------------------------------------------------------
*****************************************************************************
Here is an example of the votes
1YYYYYYYYYYThe New Guy
2YNYNYNYNYNThe Captain
2YNNYYNNYYNThe Captain
2NNNNNNNNNNThe New Guy
3NYNYNYNYNYThe New Guy
3YYYYYYYYYYThe Captain
3YYYYYYYYNYThe Captain
3YYYNNYYYYYThe Captain
4NNYYYNYYYYThe Captain
4NYYYYYYYYYThe Captain
5YYYYYYYNNYThe Captain
6YYNYNYYYYYThe Captain
7YNYNYNYNYNThe New Guy
9YNYNYNYNYNThe Captain
9YNNYYNNYYNThe Captain
10NYNYNNYNYNThe New Guy
****************************************************************************


I will now attach what Code I have now

********************************************************************************

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
 
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;
void createarray();
string myfile ();

//Function for array creation "createarray"
void createarray ()
{
 std::ifstream in("input.txt");
    std::stringstream buffer;
    buffer << in.rdbuf();
    std::string input = buffer.str();
    std::cout << input << std::endl << std::endl;




    // Create array

     std::string votes[100]; 


}





void checkdup ()
{
    int arrLength = 99;

     std::ifstream in("input.txt");
    std::stringstream buffer;
    buffer << in.rdbuf();
    std::string input = buffer.str();
 std::string nodup[100];



}








int main()
{
cout <<"Here is the raw data for the votes, these include any duplicates."<<endl; //used to test each function
createarray();
cout << "Here is the file without duplicates"<<endl;
checkdup();

}


I am stuck on the function that checks for duplicates and reads into another array and file the non duplicates and into an array only, the duplicates.


Last edited on
Topic archived. No new replies allowed.