Lines in blue are comment lines explaining changes made to the original
program, samp1.f.
Lines or line segments in red are the lines/segments modified or added.
C** Change the length of the character
C variables from 6 to 8
character*8 date1,date2,date1p,date2p
character *20 name1,name2
character*3 month(12)
integer m1,m2,d1,d2,y1,y2
data month/'Jan', 'Feb', 'Mar',
1 'Apr', 'May', 'Jun', 'Jul',
2 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'/
read(*,'(a)')name1
read (*,'(a)')date1
read(*,'(a)')name2
read (*,'(a)')date2
C** Replace format 3i2 with 2i2,i4 in
C the next two lines
read(date1,'(2i2,i4)')m1,d1,y1
read(date2,'(2i2,i4)')m2,d2,y2
C** Replace 6 with 8 in the next two lines.
date1p = date1(5:8)//date1(1:2)//date1(3:4)
date2p = date2(5:8)//date2(1:2)//date2(3:4)
if(date1p.eq.date2p)then
C** Replace 1900+y1, 1900+y2 with y1
C and y2 in the following lines.
print *, name1,' with birth date: ', month(m1),' ',d1,', ',
1 y1
print *
print *, 'is the same age as'
print *
print *, name2,' with birth date: ', month(m2),' ',d2,', ',
1 y2
else if(date1p.lt.date2p)then
print *, name1,' with birth date: ', month(m1),' ',d1,', ',
1 y1
print *
print *, 'is older than'
print *
print *, name2,' with birth date: ', month(m2),' ',d2,', ',
1 y2
else
print *, name1,' with birth date: ', month(m1),' ',d1,', ',
1 y1
print *
print *, 'is younger than'
print *
print *, name2,' with birth date: ', month(m2),' ',d2,', ',
1 y2
endif
end