can someone help me to do the
program that reads age of a person and tells wether the person can vote or not. Ages should be written in a text file and output whoud be displayed in the console. Refer to the text file below. Your program should define a function with the following prototype.
Person 1 can vote.
Person 2 can vote.
Person 3 cannot vote.
Person 4 cannot vote.
Person 5 cannot vote.
Person 6 can vote.
Person 7 cannot vote.
Person 8 cannot vote
Input File: age.txt
A negative value serves as a dummy input. The program stops reading as soon as a negative value is read. However, it will not be recognized as an age.
I worked on a very similar problem in a Logic class with flowcharts. I haven't done this with code yet though. I'm not sure what to tell you without spoiling some of the assignment. =\
Just write down your Input, Processing, and Output, and what needs to be done.
You might want to open up that txt file for read via <fstream>, read it line by line, then insert each line into your function to check IF the number is what you desire, then simply create outputs accordingly.