Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
MODULE guessf;
|
||||
|
||||
IMPORT InOut, Random, NumConv, Strings;
|
||||
|
||||
VAR number, guess : CARDINAL;
|
||||
input : Strings.String;
|
||||
OK, Done : BOOLEAN;
|
||||
|
||||
BEGIN
|
||||
number := Random.nr (1000);
|
||||
InOut.WriteString ("I have chosen a number below 1000; please try to guess it.");
|
||||
InOut.WriteLn;
|
||||
REPEAT
|
||||
REPEAT
|
||||
InOut.WriteString ("Enter your guess : "); InOut.WriteBf;
|
||||
InOut.ReadString (input);
|
||||
NumConv.Str2Num (guess, 10, input, OK);
|
||||
IF NOT OK THEN
|
||||
InOut.WriteString (input);
|
||||
InOut.WriteString (" is not a valid number...");
|
||||
InOut.WriteLn
|
||||
END
|
||||
UNTIL OK;
|
||||
InOut.WriteString ("Your guess is ");
|
||||
IF number = guess THEN
|
||||
Done := TRUE;
|
||||
InOut.WriteString ("spot on!")
|
||||
ELSE
|
||||
Done := FALSE;
|
||||
IF guess > number THEN
|
||||
InOut.WriteString ("too high.")
|
||||
ELSE
|
||||
InOut.WriteString ("too low.")
|
||||
END
|
||||
END;
|
||||
InOut.WriteLn
|
||||
UNTIL Done;
|
||||
InOut.WriteString ("Thank you for playing; have a nice day!");
|
||||
InOut.WriteLn
|
||||
END guessf.
|
||||
Loading…
Add table
Add a link
Reference in a new issue