To create a game of Heads or Tails against the computer.
Write a program that asks the user for Heads or Tails, then simulates a toss of a coin and then tells the user whether they have guessed correctly.
Please help me to solve the above problem.Code:DISPLAY a title for the program Issue the statement that stops the random numbers always coming out as zero Ask the user for Heads or Tails INPUT guess Generate a random number less than 2 call this computer IF computer=0 THEN SET coin = h OUTPUT computer tossed a Head ELSE SET coin=t OUTPUT Computer tossed a tail ENDIF IF coin=guess THEN OUTPUT You won ELSE OUTPUT You lost ENDIF
Last edited by WingedPanther; 02-27-2009 at 09:07 AM. Reason: add code tags (the # button)
It looks like your logic is correct. How far have you gotten in coding it?
Thank you for your prompt reply. I know it is a basic concept of Pascal / Delphi. But how can I convert the pseudocode to Delphi:
DISPLAY a title for the program
Issue the statement that stops the random numbers always coming out as zero
Ask the user for Heads or Tails
INPUT guess
Generate a random number less than 2 call this computer
IF computer=0 THEN
SET coin = h
OUTPUT computer tossed a Head
ELSE
SET coin=t
OUTPUT Computer tossed a tail
ENDIF
IF coin=guess THEN
OUTPUT You won
ELSE
OUTPUT You lost
ENDIF
Please help me to solve the above problem.
If this is going to be a Windows based program, you need to create a forum.
If you're doing a forum-based program, you need to decide out the screen will be laid out, including input/output fields and triggers for processing.
If you're doing a console application, you'll need to using the basic input/output for consoles.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks