(* stringtest.pas - Let's practice working with strings. *) program stringtest; var s, DigitString : string; i, CountT, location, CountVowels : integer; found : boolean; begin (* input *) write('Please enter a string to test with: '); readln(s); (* 1. Count how many times the capital letter T appears. *) CountT := 0; (* YOU NEED TO INSERT A LOOP HERE *) writeln('I found this many occurrences of capital T: ', CountT); (* 2. Find location of first capital T. * Replace the assignment statement below with the correct * computation for the location. *) location := -1; writeln('The first T appears at position ', location); (* 3. Is the length of the string more than 5? * Replace the "false" with the correct condition. *) if false then writeln('The string''s length is more than 5.') else writeln('The string''s length is 5 or less.'); (* 4. What is the 5th character of the string? * Complete the writeln statement with the correct expression. *) if length(s) >= 5 then writeln('The 5th character of the string is ', 'replace me'); (* 5. What are the last 3 characters? * Complete the writeln statement with the correct expression. *) writeln('The last three characters are ', 'replace me with the correct expression'); (* 6. Are the first and last characters the same? * Replace the "false" in the following if-statement. *) if false then writeln('The first and last characters are the same.') else writeln('The first and last characters differ.'); (* 7. Are all the letters capitalized? * Replace the "false" in the following if-statement. *) if false then writeln('I found at least one lowercase letter.') else writeln('All the letters are capitalized.'); (* 8. Count the vowels. Are there at least 2? * From now on, let's assume all the letters are capitalized * so that we don't have to look for both capital and lowercase * versions of each letter. *) s := upcase(s); CountVowels := 0; (* WRITE A LOOP THAT COUNTS THE VOWELS. *) writeln('I found this many vowels: ', CountVowels); if CountVowels >= 2 then writeln('There are at least 2 vowels.') else writeln('The number of vowels is less than 2.'); (* 9. Does the string contain any digits? *) found := false; DigitString := '0123456789'; (* WRITE A LOOP THAT DETERMINES IF ANY CHARACTER IN s IS A DIGIT. * IF SO, SET FOUND TO TRUE. *) if found then writeln('I found at least one digit in the string.') else writeln('The string has no digits.'); end.