Can Anyone Help in writing a Pascal Program

Quote:

>I need to write a program that simulates Las Vegas Craps. The program

>should generate a pair of random numbers between 1 and 6. The program

>should play one hundred games and count the number of wins and loses. It

>also needs to print out the percentage of wins and loses. Please help... I

>havn't programmed in over 20 years.

20 years is a long time not to have written a program! Hope this will

aim you in the right direction. First, look up RANDOMIZE and RANDOM in

your online help and see how these work. In some dialects, RANDOM(20)

will generate the numbers 0..19 which you can add 1 to to cover 1..20.

In some dialects, a real number .000... to .999999... is generated.

Multiplying this by 20 and rounding to an integer, which you can find

in your help also, will again generate 0..19. You only need one

RANDOMIZE in the body of your program.

You "roll" your random generator twice to get 1..6 and add the two

numbers to get your point. There are many variations of Craps and the

Las Vegas method is designed to increase the house percentage! The

following assumes simpler rules. On the first roll of the dice if you

roll a 7 or 11, you win. Otherwise you take as many rolls as you can

(without rolling a 7 or 11) to roll the same point as made on the

first roll. After a "point" roll, 7 or 11 loses. If it were me, I

would try this version first and then add the conditions you require

later. This is also a test of "good" programming technique. Write your

program such that it is easily modified. Using CONST, PROCEDURE and

FUNCTION makes for a good "tops down" method of programming which is a

strong point of PASCAL.

A DO loop is suggested to keep up with the number of games played. An

integer variable, 'win' for example, should be initialized to 0 and

then incremented, INC(win), each time you have a winner. Nested within

the DO loop you have other loop(s) of the REPEAT or WHILE type. To

check for wins/losses you need conditional comparisons of the

IF..THEN..ELSE or CASE kind.

Don't try to write the whole program at once. I suggest you write a

loop that will show 20 random numbers in the 1..6 range and display

them on the screen and go from there.

Although I am sure you want to do this by yourself as much as

possible, feel free to send email for hints, clarification or where to

look for help.

Regards,