my file is giving all correct numbers except # 6 and #7 i am short by 1 on both and i dont know why
here is the instruction
Construct program that will analyze a voting file. The /program should generate the following totals:
1. Number of males not eligible to register.
2. Number of females not eligible to register.
3. Number of males who are old enough to vote but have not registered.
4. Number of females who are old enough to vote but have not registered.
5. Number of individuals who are eligible to vote but did not vote.
6. Number of individuals who did vote.
7. Number of records processed.
The file name is vote.txt and is organized in the following manner:
Field 1 Field 2 Field 3 Field 4 Field 5
ID Number Age Gender Registered Voted
ID Number is 4 characters
Age is a number
Gender is either an F or a M
Registered is either an N or a Y
Votes is either an N or a Y
the file only has this information on it.
1812 23 M Y Y
1951 37 F Y Y
4516 15 F N N
1654 19 M Y N
2145 18 F N N
6233 21 F Y Y
9127 22 M N N
3215 26 F Y Y
2201 33 F Y N
7743 41 M Y Y
1121 51 F Y Y
1949 17 M N N
------------------------------------------
here is my code.
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
int malesNotEligToRegister = 0;
int femalesNotEligToRegister = 0;
int malesOldEnoughToVoteButNotRegistered = 0;
int femalesOldEnoughToVoteButNotRegistered = 0;
int eligToVoteButDidNotVote = 0;
int individualsWhoDidVote = 0;
int recordsProcessed = 0;
int age;
string idnumber, gender, registered, voted;
ifstream fin;
fin.open("i:\\vote.txt");
fin >> idnumber >> age >> gender >> registered >> voted;
while (!fin.eof())
{
fin >> idnumber >> age >> gender >> registered >> voted;
recordsProcessed++;
}
cout << "1. Total Males not eligible to register....................: " << malesNotEligToRegister << endl;
cout << "2. Total Females not eligible to register..................: " << femalesNotEligToRegister << endl;
cout << "3. Total Males old enough to vote but have not registered..: " << malesOldEnoughToVoteButNotRegistered << endl;
cout << "4. Total Females old enough to vote but have not registered: " << femalesOldEnoughToVoteButNotRegistered << endl;
cout << "5. Total eligible to vote but did not vote.................: " << eligToVoteButDidNotVote << endl;
cout << "6. Total eligible to vote and did vote.....................: " << individualsWhoDidVote << endl;
cout << "7. Total records processed.................................: " << recordsProcessed << endl;
cout << endl;
cout << endl;