Type the following program exactly as shown:
program Lab5
implicit none
! This program introduces Fortran string handling capabilities
character*26 upper, lower, name, cap
character str*2, one*1
integer*2 from, to, i, m
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
name = "York University"
! ----------------------------------------------------------Substrings:
do i = 1, 5
print*, "The string we are studying is: ", name
print*, "Enter two integers ..."
read*, from, to
print*, name(from : to)
end do
! ----------------------------------------------------------Pattern:
do i = 1, 5
print*, "Enter any 2-character string (e.g. enter er) ..."
read 5, str
print*, index(name, str)
end do
5 format(A)
! ----------------------------------------------------------Capitalize:
do i = 1, len(name)
one = name(i : i)
m = index(lower, one)
if (m .ge. 1 .and. m .le. 26) then
one = upper(m : m)
end if
cap(i : i) = one
end do
print*, cap
! ----------------------------------------------------------Frequency:
print*, "Enter any single character to count its occurrences in ", name
read 5, one
end