Sign in to follow this  
TweedleDum101

BlackJack

Recommended Posts

i have this program i have to write that is due tomorrow(friday December 3rd) and i was hoping that you guys could help me out but if not that is okay too. it is in future basic and dont get to complicated, here is the what my teacher gave me: Write a program to simulate a simplified version of the game blackjack. a deck of cards numbered 1 to 10 is used. and any number can be repeated since the deck contains many cards. the computer starts by asking you how many cards you want. it then reals the randomly picked cards and prints them, and totals their value. if the value exceeds 21, you automatically lose. if your value is under 21, the computer deals itself 3 randomly picked cards, prints them and totals their value. if the computer;s total is greater than 21, you automatically win. if neither score exceeds 21, the highest score wins. This program must be written so it can be played 10 times. the program should also keep track of how many games are won by each player and how many ties. At the end of the 10 games, the program should print the results. Here is example of a sample run hand #1 How many cards do you want? 2 You: 7 9 Me: 1 9 10 I have 20 and you have 16. I win! and when it is all done it should print this: Game Total: Player Wins = 2 Computer Wins = 7 Ties = 1

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Homework questions are generally frowned upon here, I'm afraid. To quote from the Forum FAQ:

Quote:

Programmers, please Note; You should be committed to learning. Dedicate yourself to spending a lot of time solving problems. You can't expect to learn anything if you're going to have others write your code for you.


With that in mind you'll probably get a much better answer if you post a particular issue you're having (ie I've tried this code and can't see why it's not working, can anyone point out where I might be going wrong).

Sorry if that's not what you want to hear,
Jim.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
With that in mind you'll probably get a much better answer if you post a particular issue you're having (ie I've tried this code and can't see why it's not working, can anyone point out where I might be going wrong).
What he said. Asking questions which relate to your homework isn't a problem per se, but nobody's about to do the work for you.

The program you've described sounds reasonable and achievable, so which aspect of it would you like help with?

Share this post


Link to post
Share on other sites
ok got a pretty good start on my program, but i dont know what is wrong, it only asks how many cards you want and keeps asking that, it does not print the cards you want, here it is:
'------Functions-------
BREAK ON

LOCAL FN initalizeWindow 'opens window
WINDOW 1, "Blackjack", (0,0)-(300,300)
END FN

LOCAL FN CgetCards!(Ccards)
LONG IF ccard=3
cnum1!=RND(3)
cnum2!=RND(3)
cnum3!=RND(3)
PRINT "His: "cum!;cnum!;cnum!
cTotal! = (cnum1!+cnum2!+cnum3!)
END IF
END FN = cTotal!

LOCAL FN MgetCards! (Mcards)
LONG IF howmny!=1
Mnum1=RND(10)
PRINT "Yours: "Mnum1
mTotal=(Mnum1) 'shows card
LONG IF howmany!=2
Mnum1=RND(10)
Mnum2=RND(10)
PRINT "Yours: "Mnum1;Mnum2
mTotal=(Mnum1+Mnum2) 'adds cards together
LONG IF howmany!=3
Mnum1=RND(10)
Mnum2=RND(10)
Mnum3=RND(10)
PRINT "Yours: "Mnum1;Mnum2;Mnum3
mTotal=(Mnum1+Mnum2+Mnum3) 'adds cards together
LONG IF howmny!=4
Mnum1=RND(10)
Mnum2=RND(10)
Mnum3=RND(10)
Mnum4=RND(10)
PRINT "Yours: "Mnum1;Mnum2;Mnum3;Mnum4
mTotal=(Mnum1+Mnum2+Mnum3+Mnum4) 'adds cards together
END IF
END IF
END IF
END IF
END FN =mTotal

LOCAL FN plyhands 'this is the actual game
PRINT"Welcome to Blackjack, Hope You Have Fun!"
hand = 1
FOR hand = 1 TO 10
INPUT "How Many Cards Do You Want? (1-4)";Mcards
FN MgetCards!(Mcards)
FN CgetCards!(Ccards)

LONG IF mTotal>21
PRINT "You Lose"mTotal
XELSE
LONG IF cTotal> 21
PRINT "The Computer Busted You Win!"
XELSE
LONG IF mTotal<21AND cTotal!<21
PRINT "Your Total is: "mTotal
PRINT "The Computers Total is: "cTotal!
END IF
END IF
END IF
NEXT
END FN

'-------Main Program------
FN initalizeWindow
FN plyhands

oh and i still need to print the wins loses and ties.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this