Yo,
For the 3-digit number from 576 to 601 you might get in trouble: if more than 13 females or more than 13 males are born on one day, you'll have a number larger than 601.
As for assisting: you need to know whether the person is male or female.
1 2
|
bool female_male;
cout << "Are you female or male? 0=female, 1=male\n"; cin >> female_male;
| |
You need two integers to keep track of females and males:
1 2
|
int femalecounter = 565;
int malecounter = 564;
| |
And you need an if-statement:
1 2
|
if (female_male == 0) femalecounter+2;
if (female_male == 1) malecounter+2;
| |
This only makes sense if you put
everything in a loop, except the initializations (string year; -- int malecounter;). You can use a
for
loop, for example.
Concerning the control number, consider string function
at
:
1 2 3
|
string year = 08;
char firstdigitchar = year.at(0);
char seconddigitchar = year.at(1);
| |
This gets you the first and second digit.
Another thing you would want to do is convert the strings and chars to signed integers. Google "string char integer" and you might find something useful. You need to do conversions in order to be able to calculate using the value in chars and strings. E.g,
1 2
|
int firstdigit = (int) firstdigitchar - '0'; // substract the char value of 0 to get the int
firstdigit = firstdigit*2;
| |
Hope this gets you on the way!