Public Group

# BlackJack

This topic is 5090 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 on other sites
Quote:
 Original post by Anonymous PosterWith 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 on other sites
Yeah thats okay, thanks guys, ill post my code when i get farther done with it

##### 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
LONG IF howmany!=3
Mnum1=RND(10)
Mnum2=RND(10)
Mnum3=RND(10)
PRINT "Yours: "Mnum1;Mnum2;Mnum3
LONG IF howmny!=4
Mnum1=RND(10)
Mnum2=RND(10)
Mnum3=RND(10)
Mnum4=RND(10)
PRINT "Yours: "Mnum1;Mnum2;Mnum3;Mnum4
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 "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.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633322
• Total Posts
3011353
• ### Who's Online (See full list)

There are no registered users currently online

×