#include #include // This code will tally votes for the 2004 Election! int main (int argc, char *args) { // These variables will keep track of how many votes each candidate has int kerry = 0, nader = 0, bush = 0, other = 0; // This variable is important because we store our characters here. int Input; while ((Input=getchar())!=EOF) { unsigned char Vote=Input; if (!isspace(Vote)) { if ((Vote == 'b') || (Vote == 'B')) { // bush--; // Since the voter is a Republican, we should subtract a vote... bush++; } else if ((Vote == 'K') || (Vote == 'k')) { // if ((rnd % 2) == 0) kerry++; // Voter might flip flop over whether he votes for Kerry... kerry += 1; } else if ((Vote == 'n') || (Vote == 'n')) { // bush++; // A vote for Nader is a vote for Bush... ++nader; } else { // Since the vote is not for one of the main three candidates, we // increment the other variable! other = other + 1; } } } // Let's print our results!!!! Yipeee! printf("Kerry %d\n",kerry); printf("Bush %d\n",bush); printf("Nader %d\n",nader); printf("Other %d\n",other); // This is the grand total! printf("Total votes is %d\n", kerry+bush+other+nader); return 0; }