program sets; (* Program to test translation of sets *) type CharSet = SET OF CHAR; var Answer : CHAR; Line : STRING[80]; Digits, UpperCase, LowerCase : CharSet; I, Digit_Count, Lower_Count, Upper_Count, Others : INTEGER; begin (* Initialize character sets *) Digits := ['0'..'9']; LowerCase := ['a'..'z']; UpperCase := ['A'..'Z']; repeat (* Initialize counters *) Digit_Count := 0; Upper_Count := 0; Lower_Count := 0; Others := 0; writeln('Type a line up to 80 characters '); readln(Line); writeln; for I := 1 TO Length(Line) do if Line[I] in Digits then Digit_Count := Digit_Count + 1 else if Line[I] in LowerCase then Lower_Count := Lower_Count + 1 else if Line[I] in UpperCase then Upper_Count := Upper_Count + 1 else Others := Others + 1; writeln('You typed ',Length(Line),' characters with '); writeln(Digit_Count:2,' digits'); writeln(Upper_Count:2,' upper case letters'); writeln(Lower_Count:2,' lower case letters'); writeln(Others:2,' other characters'); writeln; WRITE('Want to type another line? (Y/N) '); readln(Answer); writeln; until Answer <> 'Y'; end.