Closed Thread
Results 1 to 4 of 4

Thread: Please help to create a game of Heads or Tails

  1. #1
    turbomen is offline Newbie
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Smile Please help to create a game of Heads or Tails

    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.
    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
    Please help me to solve the above problem.
    Last edited by WingedPanther; 02-27-2009 at 09:07 AM. Reason: add code tags (the # button)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Please help to create a game of Heads or Tails

    It looks like your logic is correct. How far have you gotten in coding it?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    turbomen is offline Newbie
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Re: Please help to create a game of Heads or Tails

    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.

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Please help to create a game of Heads or Tails

    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How To Create A Game Editor?
    By deedo in forum General Programming
    Replies: 6
    Last Post: 03-16-2011, 12:35 PM
  2. Can I create a .bin file for my game?
    By mormollio in forum Computer Software/OS
    Replies: 1
    Last Post: 12-01-2010, 08:01 PM
  3. How to create a text based web browser game
    By Vswe in forum Tutorials
    Replies: 8
    Last Post: 03-23-2010, 04:44 PM
  4. can I use C++ to create 2 player internet game?
    By rainingmisery in forum C and C++
    Replies: 9
    Last Post: 06-20-2009, 03:11 PM
  5. If you could create a game
    By DevilsCharm in forum Video Game Talk
    Replies: 21
    Last Post: 03-22-2009, 10:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts