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.

Results 1 to 6 of 6

Thread: Black Jack for dr. java

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Black Jack for dr. java

    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


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Black Jack for dr. java

    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?

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Black Jack for dr. java

    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;
    }
    }
    }
    }

  4. #4
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Black Jack for dr. java

    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?

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Black Jack for dr. java

    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.

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Black Jack for dr. java

    Please post your code correctly. You can edit your post.

Similar Threads

  1. Black Jack: How would it look?
    By Javaconfused80850 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 30th, 2013, 06:22 PM
  2. JAVA game black jack need help on finding an error!!
    By Clyde90 in forum What's Wrong With My Code?
    Replies: 14
    Last Post: June 13th, 2012, 08:40 AM
  3. black jack game
    By 314159 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 6th, 2011, 10:42 AM
  4. (URGENT) Plz help me with the black jack program.
    By diogo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 4th, 2011, 04:08 AM
  5. Black Jack Statistics game? lost.
    By mindlessn00b in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 20th, 2010, 07:20 AM