Advertisement
pseudocreator

analysis of entered characters (very basic)

Mar 23rd, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE analyzechar;  
  2. FROM InOut IMPORT WriteString, WriteLn, Read, Write;
  3. TYPE
  4.     letters = SET OF ['A'..'z'];
  5.     digits = SET OF ['0'..'9'];
  6. VAR
  7.    allvowels, allconsonants: letters;
  8.    alldigits : digits;
  9.    ch : CHAR;
  10. CONST
  11.      empty = letters{};
  12.      wovels = letters{'A', 'E', 'I', 'O', 'U'};
  13.      consonants = letters{'A'..'Z'} -  wovels;
  14.      dig = digits{'0'..'9'};
  15.  
  16. BEGIN
  17.      allvowels := empty;
  18.      allconsonants := empty;
  19.      alldigits := digits{};
  20.      WriteString('Enter the text block that you want to analyze');
  21.      WriteLn; WriteString('Finish your entering with a dot!');
  22.      WriteLn;
  23.      Read(ch);
  24.      WHILE ch <> '.' DO  
  25.      (*everything is written correctly*)
  26.      (*but function CAP in some versions of the module2*)
  27.      (*from some reason doesn't work corectly!*)
  28.          IF CAP(ch) IN wovels THEN            
  29.           INCL(allvowels,ch)
  30.         END;
  31.         IF CAP(ch) IN consonants THEN
  32.           INCL(allconsonants,ch)
  33.         END;
  34.         IF ch IN dig THEN
  35.           INCL(alldigits,ch)
  36.         END;
  37.         Read(ch);
  38.    END;
  39.    WriteLn;
  40.    WriteString('All the vowels, which are found in the text, are: ');
  41.    WriteLn;
  42.    FOR ch := 'A' TO 'Z' DO
  43.       IF ch IN allvowels THEN
  44.         Write(ch);
  45.         WriteString('  ');
  46.       END
  47.    END;
  48.    WriteLn;
  49.    WriteString('All the consonants, which are found in the text, are: ');
  50.    WriteLn;
  51.    FOR ch := 'A' TO 'Z' DO
  52.       IF ch IN allconsonants THEN
  53.         Write(ch);
  54.         WriteString('  ');
  55.       END
  56.    END;
  57.    WriteLn;
  58.    WriteString('All the numbers which have been found in the text, are: ');
  59.    WriteLn;
  60.    FOR ch := '0' TO '9' DO
  61.       IF ch IN alldigits THEN
  62.         Write(ch);
  63.         WriteString('  ');
  64.       END
  65.    END;
  66. END analyzechar.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement