var num,guess,tries,win:int
loop
win:=0
tries:=7
num:=Rand.Int(1,100)
put "Guess the number between 1 and 100 in seven tries."
loop
get guess
if guess>num and guess<101 then
tries:=tries-1
put "You guessed too high!"
if tries>0 then
put "Try again. You have ",tries," tries left."
end if
elsif guess<num and guess>0 then
tries:=tries-1
put "You guessed too low!"
if tries>0 then
put "Try again. You have ",tries," tries left."
end if
elsif guess=num then
put "You got it!"
win:=1
else
put "Invalid entry."
end if
exit when tries=0 or win=1
end loop
if win=1 then
put "You won!"
elsif win not=1 then
put "You lost! Try again."
end if
end loop
|