PROG8.PAS 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. PROGRAM PROG8;
  2. {$U+ Copyright (C), 1985 by Lyle Faurot. All rights reserved.
  3. New Topics: CASE statement
  4. Block statement
  5. }
  6. VAR
  7. Response : Char;
  8. Correct_Response : Boolean;
  9. BEGIN
  10. WriteLn('Turbo Pascal seems to ');
  11. WriteLn;
  12. WriteLn('A. Run faster than other Pascals.');
  13. WriteLn('B. Compile faster than others.');
  14. WriteLn('C. Take less room in memory.');
  15. WriteLn('D. All of the above.');
  16. WriteLn;
  17. REPEAT
  18. Write('Enter your choice - A, B, C, or D: ');
  19. ReadLn(Response);
  20. WriteLn;
  21. CASE Response OF
  22. 'A','a',
  23. 'B','b',
  24. 'C','c' : BEGIN
  25. WriteLn('Correct, but not the best answer.');
  26. WriteLn('Please try again.');
  27. Correct_Response := False;
  28. END;
  29. 'D','d' : BEGIN
  30. WriteLn('Correct - these all seem to be true.');
  31. Correct_Response := True;
  32. END;
  33. ELSE
  34. BEGIN
  35. WriteLn(Response,' was not one of the choices. Try again.');
  36. Correct_Response := False;
  37. END;
  38. END; {CASE}
  39. UNTIL Correct_Response;
  40. END.
  41.