Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Need Urgent Help!

  1. #1

    Need Urgent Help!

    Hi people,

    I'm a student teacher in training studying program languages in order to teach it one day, and i have been assigned to learn Pascal. I also need to construct a Heads or Tales game for studnets, where they enter their selection and the program generates a head or a tale to determin if the user made the right choice. So anyways a very basic heads or tales program..

    Is there anybody out there that can help me, i have no experience with programing languages whatsoever.

  2. #2

    Need Urgent Help!

    You need to teach programming and can't program?? :shock:

    Download Free Pascal right away:

    http://www.freepascal.org

    Here is a good tutorial to learn programming: :read:

    http://www.taoyue.com/tutorials/pascal/

    Make sure the tutorial has no secrets for you. As soon that is done, you you can start to think about the problem you are proposing.

  3. #3

    Need Urgent Help!

    i would need to teach programming in the future, bot just yet though. At the moment i just need to creat a program for an assignment, which can be used once i start teaching.

  4. #4

    Need Urgent Help!

    hi out there,

    this is what i have so far for the heads or tales programe, i'm getting an error and don't know how to fix it...

    [pascal]program heads_tales
    var
    HoT,
    RandomNumber : interger;
    begin (* heads or tales *)
    writeln ('This is a game of heads or tales');
    writeln ('Press 1 for heads or 2 for tales, and then ENTER');
    write ('Enter 1 or 2');
    writeln ('Thanks for your choice.');
    Read (HoT);
    RandomNumber = random(1)
    if RandomNumber = HoT then
    begin
    writeln ('Looks like your choice won!');
    end;
    else
    begin
    writeln ('Sorry! Try again.')
    end;
    end.[/pascal]

    Any suggestions to fixing the coding

    [size=9px](EDIT by WILL: Fixed for the visitor's viewing pleasure. )[/size]

  5. #5

    Need Urgent Help!

    Yes:
    * Place a ; after the program statement.
    * Place a ; after random(1)
    * Remove the ; before else
    * It is "integer, not "interger".
    * Use := in assigments, not =

    Further, random(1) returns 0 or 1, not 1 or 2, so you will want to use random(1)+1

    Many of these errors, escpecially the ; ones can be very easily solved by looking at the compiler error messages.

  6. #6

    Need Urgent Help!

    well firstly you cant have an ; before an else statement

    Code:
      writeln ('Looks like your choice won!'); 
    end; 
    else
    (damn, he beat me to it)

  7. #7

    Need Urgent Help!

    same here, was busy in my baby. 5 post

    Only suggestion I’m left to give is, use the Pascal tag for posting code. and it will be nice to get the compiler's error/warning messages.
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  8. #8

    Need Urgent Help!

    here's the new and improved code, thanks to your help

    [pascal] program heads_tails;
    var
    HoT,
    RandomNumber : integer;
    begin
    writeln ('This is a game of heads or tales');
    writeln ('Press 1 for heads or 2 for tales');
    write ('Enter 1 or 2');
    writeln ('Thanks for your choice.');
    Read (HoT);
    RandomNumber := Random(1)+1;
    if RandomNumber = HoT then
    writeln ('Looks like your choice won!')
    else
    writeln ('Sorry! Try again.')
    end.[/pascal]

    I think it works, i just can't really see what's going on,
    even when i when i select the user screen from the debug menu of the compiler.

    Any suggestions on how to make it better than what it is?
    I would appreciate to hear back from you.

    Thanks

  9. #9

    Need Urgent Help!

    What kind of compiler are you using?

    One way to improve this program is to ask for the user if he wants to play again, instead of ending it after his first go.
    You could also ask the player for his name at the start of the program and make the resulting comment a bit more personal.

  10. #10

    Need Urgent Help!

    i am using free pascal...
    i haven't looked at loop construction yet

Page 1 of 2 12 LastLast

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
  •