NTC0394
Programmer
- Jun 19, 2013
- 21
I am trying use date_and_time to calculate how old someone are but I am having some problems about how
change characters to integers. Please, help me!!
Thank you in advance
PROGRAM how_old
IMPLICIT none
INTEGER, PARAMETER :: m_year = 12
INTEGER :: m_born, year_born , day_born, how_old
INTEGER :: current year, current_month, current_day
***********my problem************************
CHARACTER(8) :: dat
! call current date
CALL date_and_time( DATE=dat )
*********************************************
PRINT *, "Write the day you was born and press ENTER:"
READ *, day_born
PRINT *, "Write the month you was born and press ENTER:"
READ *, m_born
PRINT *, "Write the year you was born and press ENTER:"
READ *, year_born
how_old = ((current_year - year_born)*m_year + current_month - m_born)/m_year
PRINT *, "You are ", how_old," years"
END PROGRAM how_old
change characters to integers. Please, help me!!
Thank you in advance
PROGRAM how_old
IMPLICIT none
INTEGER, PARAMETER :: m_year = 12
INTEGER :: m_born, year_born , day_born, how_old
INTEGER :: current year, current_month, current_day
***********my problem************************
CHARACTER(8) :: dat
! call current date
CALL date_and_time( DATE=dat )
*********************************************
PRINT *, "Write the day you was born and press ENTER:"
READ *, day_born
PRINT *, "Write the month you was born and press ENTER:"
READ *, m_born
PRINT *, "Write the year you was born and press ENTER:"
READ *, year_born
how_old = ((current_year - year_born)*m_year + current_month - m_born)/m_year
PRINT *, "You are ", how_old," years"
END PROGRAM how_old