
-----------------------------------
jamestur
Fri Jan 15, 2010 7:30 pm

Black Jack trouble
-----------------------------------

Need help,
my program has multiple problems, First problem is that i can continue to hit as long as i want, also in the event the dealer busts and player total is less than or equal to 21 chip total is not changed, and the dealers final total remains the same throughout the program, and dealer can go over and still win.

P.S : I'm not very good at Turing, nor am I familiar with much terms beyond a grade 10 level.

Here's what I have so far,

%Beginning of Program

var pt, dt, pt2, dt2, num1, num2, chips, wager : int

var hit : string


chips := 1000
put "You have ", chips, " chips, how much do you want to wager?"
loop

    loop
        % loop
        pt := Rand.Int (1, 11)
        pt2 := Rand.Int (1, 11)
        dt := Rand.Int (1, 11)
        dt2 := Rand.Int (1, 11)
        pt3 := Rand.Int (1, 11)
        num1 := pt + pt2
        num2 := dt + dt2
        % put "You have ", chips, " chips, how much do you want to wager?"
        loop
            get wager
            if wager > chips then
                put "You don't have that much chips."
            elsif wager < 1 then
                put "Error try again."
            elsif not wager > chips then
                exit
            end if

        end loop
        put "Dealer shows a ", dt
        put "You have a ", pt, " and a ", pt2, " your total is ", num1, ", would you like to hit?"

        loop
            loop
                loop
                
                    get hit
                    if hit = "y" then
                        num1 := num1 + Rand.Int (1, 11)


                        put "Total is now ", num1

                    end if
                    if hit = "n" then 
                    exit
                    end if
                end loop
                exit
            end loop
            loop
                if num2 = 17
                elsif num2 > 16 then
                    exit
                end if
            end loop
            if num1 < num2 and num2 < 22 and
                    num1 >= 22 then
                put "You lose!"
                chips := chips - wager
                exit

            elsif num1 > num2 and
                    num1 