i am trying to make a black jack game for dr. java and i am a beginner to this but i have to do it for my cs class and i want to know how do i make the program deal 2 cards to the dealer as well as the player
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
i am trying to make a black jack game for dr. java and i am a beginner to this but i have to do it for my cs class and i want to know how do i make the program deal 2 cards to the dealer as well as the player
Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.
Show some code. What classes do you have? How are cards dealt?
import java.util.Scanner;
public class Deck {
public static void main(String[] args) {
int deal=(int)(11*Math.random()+1);
Scanner input = new Scanner(System.in);
int player;
int dealer;
// deal two cards to each player
System.out.println(player=deal);
System.out.println(player=deal);
System.out.println(dealer=deal);
System.out.println(dealer=deal);
// variables for when each player is finished hitting
boolean iamdone = false;
boolean dealerDone = false;
String answer;
while(!iamdone || !dealerDone) {
// player's turn
if(!iamdone){
System.out.print("Hit or Stay? (Enter H or S): ");
answer = input.nextLine();
// if the player hits
if(answer.equals("H")) {
// add next card and store whether we've busted
System.out.println(player=deal);
}
else{
iamdone = true;
}
}
// dealer's turn
if(!dealerDone) {
System.out.println("The Dealer hits");
System.out.println(dealer=deal);
}
else {
System.out.println("The Dealer stays");
dealerDone = true;
}
}
}
}
do you have to deal correct cards like 2-10, J, Q, K, A? if so youll need to set the jqka to values and show them as J Q K A and also think about the Ace can be 1 or 11 and you can split with 2 of the same cards...how in depth are you supposed to get with this program?
You do not have to go in depth. I just have to continue dealing numbers to the player and dealer if they hit if they pass 21 it's a bust.
Please post your code correctly. You can edit your post.