Not sure why code is broken

For some reason I keep getting not in scope errors and i'm unsure on how to fix them

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>

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

 //Adding Data from Source to Buffer

int Main ()
{
    

{  std::ifstream in("input.txt");
   std::stringstream buffer;
    buffer << in.rdbuf();
    std::string input = buffer.str();
    std::cout << input << std::endl << std::endl; }

//Function for Total Votes and stores value
int TVotes;
{
    TVotes =  std::ifstream("input.txt");
}

// Unique Records No Duplicates

{std::sort(nodup.begin(), nodup.end());
nodup.erase(std::unique(nodup.begin(), nodup.end()), nodup.end()); }

//Function for Finding Captain and First Mate in Unique Records

int CaptainV, NewGuyV;

//Captain
{found=nodup.find("Captain");
 if (found!=std::string::npos)
 CaptainV = std::cout << found;
}

{//New Guy
found=nodup.find("Captain");
 if (found!=std::string::npos)
 NewGuyV = std::cout << found;
}
{if (CaptainV > NewGuyV) Win = "Captain" and Win2 = "New Guy"  Else Win = "New Guy" and Win2 = "Captain"}

//Function for array for Amendments Yes and No Values

//Amendments Integer Declared for Final Tally
int ADY1, ADN1, ADY2, ADN2, ADY3, ADN3, ADY4, ADN4, ADY5, ADN5, ADY6, ADN6, ADY7, ADN7, ADY8, ADN8, ADY9, ADN9, ADY10, ADN10,

//Amendments Integer Declared and Character Positions in string
char AD1, AD2, AD3, AD4, AD5, AD6, AD7, AD8, AD9, AD10;

AD1 = nodup.substr(3,1)
AD2 = nodup.substr(4,1)
AD3 = nodup.substr(5,1)
AD4 = nodup.substr(6,1)
AD5 = nodup.substr(7,1)
AD6 = nodup.substr(8,1)
AD7 = nodup.substr(9,1)
AD8 = nodup.substr(10,1)
AD9 = nodup.substr(11,1)
AD10 = nodup.substr(12,1)

//Counting Yes and No for Amendment 1
{for (int AD1=0; i<=100; i++)
         if (AD1="Y") ADY1 = AD1+1;
         if (AD1="Y") ADN1 = AD1+1;
}

{//Counting Yes and No for Amendment 2
for (int AD2=0; i<=100; i++)
         if (AD2="Y") ADY2 = AD2+1;
         if (AD2="N") ADN2 = AD2+1;
}

{//Counting Yes and No for Amendment 3
for (int AD1=0; i<=100; i++)
         if (AD3="Y")  ADY3 = AD3+1;
         if (AD3="Y")  ADN3 = AD3+1;
}

{//Counting Yes and No for Amendment 4
for (int AD4=0; i<=100; i++)
         if (AD4="Y") ADY4 = AD4+1;
         if (AD4="Y") ADN4 = AD4+1;
}

{//Counting Yes and No for Amendment 5
for (int AD5=0; i<=100; i++)
         if (AD5="Y") ADY5 = AD5+1;
         if (AD5="Y") ADN5 = AD5+1;
}

{//Counting Yes and No for Amendment 6
for (int AD6=0; i<=100; i++)
         if (AD6="Y")  ADY6 = AD6+1;
         if (AD6="Y")  ADN6 = AD6+1;
}

{//Counting Yes and No for Amendment 7
for (int AD7=0; i<=100; i++)
         if (AD7="Y")  ADY7 = AD7+1;
         if (AD7="Y")  ADN7 = AD7+1;
}

{//Counting Yes and No for Amendment 8
for (int AD8=0; i<=100; i++)
         if (AD8="Y")  ADY8 = AD8+1;
         if (AD8="Y")  ADN8 =  AD8+1;
}

{//Counting Yes and No for Amendment 9
for (int AD9=0;i<=100;i++)
         if (AD9="Y") ADY9 = AD9+1;
         if (AD9="N") ADN9 = AD9+1;
}

{//Counting Yes and No for Amendment 10
for (int AD10=0;i<=100;i++)
         if (AD10="Y")  ADY10 = AD10+1;
         if (AD10="N") ADN10 = AD10+1;
}

//Amendment Passed Failed Percentages
//Amendment 1
{if (ADY1 > ADN1, ADY1 >74) AReport1 = "75% met" and Amend1 = "Passed" else (ADY1 > ADN1, ADY1 <51) AReport1 = "50% is not a majority" and Amend1 = "Failed"  }

//Amendment 2
{if (ADY2 > ADN2, ADY2 >74) AReport2 = "75% met" and Amend2 = "Passed" else (ADY2 > ADN2, ADY2 <51) AReport2 = "50% is not a majority" and Amend2 = "Failed"  }

//Amendment 3
{if (ADY3 > ADN3, ADY3 >74) AReport3 = "75% met" and Amend3 = "Passed" else (ADY3 > ADN3, ADY3 <51) AReport3 = "50% is not a majority" and Amend3 = "Failed"  }

//Amendment 4
{if (ADY4 > ADN4, ADY4 >74) AReport4 = "75% met" and Amend4 = "Passed" else (ADY4 > ADN4, ADY4 <51) AReport4 = "50% is not a majority" and Amend4 = "Failed"  }

//Amendment 5
{if (ADY5 > ADN5, ADY5 >74) AReport5 = "75% met" and Amend5 = "Passed" else (ADY5 > ADN5, ADY5 <51) AReport5 = "50% is not a majority" and Amend5 = "Failed"  }

//Amendment 6
{if (ADY6 > ADN6, ADY6 >74) AReport6 = "75% met" and Amend6 = "Passed" else (ADY6 > ADN6, ADY6 <51) AReport6 = "50% is not a majority" and Amend6 = "Failed"  }

//Amendment 7
{if (ADY7 > ADN7, ADY7 >74) AReport7 = "75% met" and Amend7 = "Passed" else (ADY7 > ADN7, ADY7 <51) AReport7 = "50% is not a majority" and Amend7 = "Failed"  }

//Amendment 8
{if (ADY8 > ADN8, ADY8 >74) AReport8 = "75% met" and Amend8 = "Passed" else (ADY8 > ADN8, ADY8 <51) AReport8 = "50% is not a majority" and Amend8 = "Failed"  }

//Amendment 9
{if (ADY9 > ADN9, ADY9 >74) AReport9 = "75% met" and Amend9 = "Passed" else (ADY9 > ADN9, ADY9 <51) AReport9 = "50% is not a majority" and Amend9 = "Failed"  }

//Amendment 10
{if (ADY10 > ADN10, ADY10 >74) AReport10 = "75% met" and Amend10 = "Passed" else if (ADY10 > ADN10, ADY10 <51) AReport10 = "50% is not a majority" and Amend10 = "Failed"  }

{//Printing out results
cout <<"Total Votes Cast: "  TVotes <<endl;
cout<< "Captain Votes: " CaptainV + "The New Guy Votes: " + NewGuyV <<endl;
cout<< "Actual Privates Voted " + nodup <<endl;
cout<< "Amendment #1 "  +  ADY1  + Amend1 + "(" +ADY1 + " Y, " + ADN1 + " N) - " + AReport1 <<endl;
cout<< "Amendment #2 "  + ADY2  + Amend2 + "(" + ADY2 + " Y, " + ADN2 + " N) - " + AReport2 <<endl;
cout<< "Amendment #3 "  + ADY3  + Amend2 + "(" + ADY3 + " Y, " + ADN3 +" N) - " + AReport3 <<endl;
cout<< "Amendment #4 "  + ADY4  + Amend2 + "(" + ADY4 + " Y, " + ADN4 +" N) - " + AReport4 <<endl;
cout<< "Amendment #5 "  + ADY5  + Amend5 + "(" + ADY5 + " Y, " + ADN5 + " N) - " + AReport5 <<endl;
cout<< "Amendment #6 "  + ADY6  + Amend6 + "(" + ADY6 + " Y, " + ADN6 + " N) - " + AReport6 <<endl;
cout <<"Amendment #7 "  + ADY7  + Amend7 + "(" + ADY7 + " Y, " + ADN7 + " N) - " + AReport7 <<endl;
cout<< "Amendment #8 "  + ADY8  + Amend8 + "(" +ADY8 + " Y, " + ADN8 +" N) - " + AReport8 <<endl;
cout<< "Amendment #9 "  + ADY9  + Amend9 + "(" + ADY9 + " Y, " + ADN9 + " N) - " + AReport9 <<endl;
cout<< "Amendment #10 " + ADY10  + Amend10 + "(" + ADY10 + " Y, " + ADN10 + " N) - " + AReport10 <<endl <<endl;
cout<< "The Captain is "+ Win1 + " First Mate is " Win2 <<endl;
}
}

Lots of problems with this...

1
2
3
4
5
//Counting Yes and No for Amendment 1
{for (int AD1=0; i<=100; i++)
         if (AD1="Y") ADY1 = AD1+1;
         if (AD1="Y") ADN1 = AD1+1;
}


if AD1 is Int it can't = Y
you didn't define i
if AD1 = "y" you can't add 1 to it.


The for statement should look like
1
2
3
4
5
//Counting Yes and No for Amendment 1
{for (int i=0; i<=100; i++)
// your code here
}
Topic archived. No new replies allowed.