This message was edited by iDaZe at 2003-4-6 9:55:3
:
This message was edited by Destiny007 at 2003-4-6 9:38:33
: I need to write a number guessing game that displys the following chracteristics:
:
: 1. The computer thinks of a random number between 1 and 30
: 2. The player is prompted to type in their guess
: 3. The computer provides one of the following feedback statements based on the players guess:
: - The number the player guessed is to low
: - The number the player guessed is to high
: - the number the player guessed is outside the range of the game (i.e not netween 1 and 30)
:
: 4. The game repeats steps 2 and 3 until the player guesses the correct answer where appropriate feedback is given (i.e Well done... you guessed the correct number)
:
: 5. The game then asks the player if they would like to play again
: * typing Y repeats the game with a new random number
: * typing N exits the program
:
: PLEASE PLEASE HELP IVE TRIED AND AM STRUGGLING SO ID APPRECIATE IT LOADS IF SOMEBODY COULD HELP
:
: THANKYOU X
:
:
:
something like this (typed straight into the box so I can't guaranty it's all correct but it should give you an idea)
var
Again: Char;
Num, Guess: Integer;
begin
Again := 'Y';
Randomize;
while Again = 'Y' do begin
Num := Random( 30 ) + 1;
Guess := -1;
Writeln( 'Go on, guess ...' );
while Guess <> Num do begin
ReadLn( Guess );
if ( Guess < 0 ) or ( Guess > 30 ) then
WriteLn( 'Out of range' )
else
if Guess < Num then
WriteLn( 'Too low' )
else
if Guess > Num then
WriteLn( 'Too high' )
else
WriteLn( 'Correct' )
end;
WriteLn( 'Play again? (Y/N)' );
Read( Again );
end;
end;
end;
[edit]A small note: I'm a Delphi programmer so I don't know if I used anything that's not in Pascal. If so then you'll have to solve that for yourself[/edit]