| View previous topic :: View next topic |
| Author |
Message |
paupav Master Cheater
Reputation: 13
Joined: 15 Apr 2011 Posts: 314 Location: P. Sherman 42, Wallaby Way, Sydney
|
Posted: Wed Aug 08, 2012 10:38 am Post subject: so this is my problem |
|
|
i want to make program in c++ that show exacly how old are you (how much years, months, days you have)... and im stuck, i dont know how can i do this. so on west mostly goes month,day,year and on east it goes day,month,year. so i first wanted to put string to person answer with yes or no e.g i put
| Code: |
cout << "Are you from West?";
getline(cin, countryString);
|
and then
| Code: |
if(countryString == no)
{
cout << "Enter day of birth! (only number) ";
getline(cin, myString);
stringstream(myString) >> day;
cout << "\nEnter month of birth! (only number)";
getline(cin, myString);
stringstream(myString) >> month;
cout << "\nEnter year of birth! (only number)";
getline(cin, myString);
stringstream(myString) >> year;
//cout << "\nYou have been born " << day; //verification if everything is fine
}
|
and if yes to it goes only in other order,
P.S this is only training...
Last edited by paupav on Wed Aug 08, 2012 10:41 am; edited 1 time in total |
|
| Back to top |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Wed Aug 08, 2012 10:40 am Post subject: |
|
|
| get well soon
|
|
| Back to top |
|
 |
paupav Master Cheater
Reputation: 13
Joined: 15 Apr 2011 Posts: 314 Location: P. Sherman 42, Wallaby Way, Sydney
|
Posted: Wed Aug 08, 2012 11:16 am Post subject: |
|
|
| nvm i got it only have to write inside " "
|
|
| Back to top |
|
 |
shitposter Newbie cheater
Reputation: 5
Joined: 12 Nov 2008 Posts: 15
|
Posted: Wed Aug 08, 2012 2:22 pm Post subject: |
|
|
| What the FUCK are you doing
|
|
| Back to top |
|
 |
paupav Master Cheater
Reputation: 13
Joined: 15 Apr 2011 Posts: 314 Location: P. Sherman 42, Wallaby Way, Sydney
|
Posted: Thu Aug 09, 2012 10:18 am Post subject: |
|
|
what is wrong here
| Code: |
diffDays=todaysDay-dayOfBirth;
diffMonths=todayMonth-monthOfBirth;
diffYears=todayYear-yearOfBirth;
if(diffDays >> 0)
{
diffDays + 30;
diffMonths - 1;
}
if(diffMonths >> 0)
{
diffMonths + 12;
diffYears--;
}
if(diffYears << 0)
cout << "\nWrong input!\nPlease enter real year of birth";
|
where is diffYears - difference between today day and day of birth
|
|
| Back to top |
|
 |
|