Talk About Network

Google


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 170 of 212
Post > Topic >>

here is another project...

by "jayfro" <jebefro85@[EMAIL PROTECTED] > Oct 23, 2004 at 09:23 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 positive integer for 1900-2004
If an invalid voterBirthYear is entered the programmer should re-ask the
user for a valid voterBirthYear value.
	
voterAnnualIncome	A valid entry would be a positive float in the
acceptable float range.
If an invalid unit price float is entered the programmer should re-ask the
user for a valid unit price value.
	
voterGender	This is a char – a valid entry is an M, m, F, or f
If an invalid voterGender is entered, the programmer should re-ask the
user for a valid voterGender value.
	
currentAge	This is a calculated field, not to be input by the user.
The calculation will occur in the program and a message indicating if the
individual is old enough to vote or not printed.
	
party	A valid entry would be one of 4 characters:  d, r, l, c
If an invalid party character is entered the programmer should re-ask the
user for a valid party character.
	

Processing:	
Your program will:
1.	Check 
•	voterId
•	voterFName (make sure they have a first name)
•	voterLName (make sure they have a last name)
•	birthYear
•	voterAnnualIncome (make sure there is a value)
•	voterGender
•	currentAge
•	party
If values are out of range or inaccurate, increase the error counter and
output information to specified file.  At the bottom of the output file
with errors output how many voters there are with errors.
2.	Calculate the current age of the voter – based on the current year
(current year – birth year).  

Output:
Will depend on voter information.

Requirements:
Your program must include the functions specified above in the data
structure section.  (more, if you want).
Your program must exhibit good modular programming style.  You will lose
points for poor indenting, poor variable names, and lack of internal
comments, bad logic and other items that make a program difficult to
read.

Remember:  A program that does not compile is worth 0 points.

What to hand in:    In a labeled folder place:

1.	A listing of the project code (the cpp file) containing internal
documentation.
2.	A labeled disk with the program files (cpp, dsw and dsp) located in a
project 1 folder.  Do not give me the only working copy of your project.
3.	Copies of outputs from a run.
4.	A user manual – a document that explains to another person how to use
the executable version of your program.  Make sure that it is clear to the
user what needs to be entered as correct input.  See Documentation
handout.
5.	A programmer manual – a document that involves a careful stepwise
refinement (algorithm) for the program and each function along with a
structure chart.  See documentation handout.

An example of a valid voter input file
2300	Jon	Smith	1982	20000	M	22	r
3200	Jane	Doe	1980	40000	F	24	d

An example of an invalid voter input file
900 	Jon	Smith	1982	20000	M	22	r  (invalid id number)
3200	Jane	Doe	1987	1900	F	24	d  (not of age to vote)

i havent started writing it yet, but if someone could give me some ideas,
that would be great
 




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

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Tue Jul 8 22:55:21 CDT 2008.