I need to find how many votes each one has. I have a count that counted how many candidates there are in play which was 5. And now I have a bunch of numbers from the arraylist that I need to count happy voted each candidate and the number of candidates changes depending on which arraylist I use but for test purposes I am using test5 which has 5.
//Numbers from arraylist:
1
1
2
5
2
5
5
5
this is my code
// My code
for (int i=1; i <output.size(); i++){
char checkBallot = output.get(i).charAt(1);
//candidate is array to track how many output as what
// output is array of numbers I want to count.
String aString = Character.toString(checkBallot);
int c = Integer.parseInt(aString);
int b = c;
for (int p= 0; p < count; p++){
if(c == p+1){
int oldvalue =0;
candidate[c] = c+ oldvalue ;
oldvalue = c ;
System.out.println("this is the counter:" +c);
}
}
I think you should get rid of
oldvalueand use++candidate[c];instead of those three lines. Assuming I understand your code, and I barely do.