Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Leda > here is another...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 171 of 212
Post > Topic >>

here is another project...

by "jayfro" <jebefro85@[EMAIL PROTECTED] > Oct 23, 2004 at 09:24 PM

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 voter’s 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




 1 Posts in Topic:
here is another project...
"jayfro" <je  2004-10-23 21:24:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 19:13:29 CDT 2008.