Features used:
Use of Input/output files, a full class with private and public members,
white space in the input file, totaling the number of individuals in each
party.
Purpose:
To write a program that will receive information from a voter through an
input file using all of the specifications below.
Input:
The voter information will be read one at a time from an input file. If a
major error occurs in the file the program will print an error message and
terminate. A major error is when a character is read instead of an integer
causing the fail bit to get turned on. The voters are to be read one at
a
time and printed to the screen and to one of two output files. One output
file will be for a voter that has no errors in its information. The
second output file will be for a voter that has inaccurate information.
All voters will be printed to the screen. Only the voters with accurate
information will be included in the totaling by party.
Data structures to use:
A class must be used containing both private and public members. The
private members are given below. The public members to be written are:
the default constructor, the constructor with arguments, the copy
constructor, the destructor, the assignment operator, and a printvoter
function( this will print to the screen a voters information). Other
possible functions and data structures may be used depending on your logic
and program design (Like print_goodfile(), print_errorfile())
Class definition
class Voter
{
private:
int voterId; // the voter id will be an integer between 100 and 10,000
input by user
char voterFName[25]; // a string with white space
char voterLName[25]; // a string with white space
int voterBirthYear; // this will be input by the user (4 digit year
required)
float voterAnnualIncome; // this will be input by the user
char voterGender; // letter F or M this will be input by the user
char currentAge; // current year minus birth year calculated in the
program
char party; //d- democrat, r republican, l liberal, c - conservative
}
Input Action
voterId A valid id number will be an integer between 1,000 and 10,000
If an invalid id number is entered the program should re-ask the user for
a valid id number.
voterFName A valid last name is a string no longer then 25 characters
the string can contain white space.
voterLName A valid last name is a string no longer then 25 characters
the string can contain white space.
voterBirthYear A valid entry would be a pos


|