code i need help with
Author |
Message |
saifhero
|
Posted: Wed Dec 12, 2012 9:03 pm Post subject: code i need help with |
|
|
Write a Turing program which asks the user to enter the current date (use 3 separate variables,
i.e. one for day, one for month, one for year), asks the user for their birth date, and then
calculates and reports how old they are (in years only). Remember to account for the situation
where they have not yet had their birthday this year. Include a proper header and full
documentation. how would i do this i really need help!! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Wed Dec 12, 2012 9:11 pm Post subject: RE:code i need help with |
|
|
What have you tried so far? |
|
|
|
|
![](images/spacer.gif) |
saifhero
|
Posted: Wed Dec 12, 2012 9:23 pm Post subject: RE:code i need help with |
|
|
Im totally new to this all, so i really dont have much |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Wed Dec 12, 2012 10:33 pm Post subject: RE:code i need help with |
|
|
What's the first thing the program does? Maybe you should start with that. |
|
|
|
|
![](images/spacer.gif) |
saifhero
|
Posted: Wed Dec 12, 2012 10:42 pm Post subject: RE:code i need help with |
|
|
%AGE PROGRAM
%DECLARATIONS
var day, month, year : int
var bday, bmonth, byear : int
var age : int
%GET ALL INFORMATION FROM THE USER
put "Enter the Current date (Day) " ..
get day
put "Enter the Current date (Month) " ..
get month
put "Enter the Current date (Year) " ..
get year
put ""
put "Now enter your Birthday "
put ""
put "Birthday (Day) " ..
get bday
put "Birthday (Month) " ..
get bmonth
put "Birthday (Year) " ..
get byear
%CALCULATE AGE
%AGE IS EQUAL TO 2012 SUBTRACT THE YEAR THE USER INPUTS
age := year - byear
put ""
put day, "/", month, "/", year
put ""
put bday, "/", bmonth, "/", byear
put "You are ", age, " years old"
i have this but it always gives the age of zero |
|
|
|
|
![](images/spacer.gif) |
Panphobia
![](http://compsci.ca/v3/uploads/user_avatars/62033050050c6b61548706.png)
|
Posted: Wed Dec 12, 2012 11:16 pm Post subject: RE:code i need help with |
|
|
working fine for me :S |
|
|
|
|
![](images/spacer.gif) |
jr5000pwp
|
Posted: Thu Dec 13, 2012 12:16 am Post subject: RE:code i need help with |
|
|
That should work, but you will need to figure out if they have had their birthday this year.
How would you go about that? Imagine if I put in my birthday as December 25th. How would you go about seeing if that birthday has passed?
An easy way to do this is to figure it out on paper, how can you explain to someone who is completely incompetent how to solve this problem? |
|
|
|
|
![](images/spacer.gif) |
|
|