We needed something fast and fun to build because the two people in our group had very little experience in any coding. We created a program that ran the cards through a strategy guide and a card counter to assist in playing blackjack on the go or online. We anticipate eventually integrating it into either a website or an app for easy use. Sorry for the ugly submission, we don't know how to compile it into anything reasonable.

import java.util.Scanner; //Program to suggest strategy and assist with betting through card counting. Intended for single deck play. public class Inputs { static String recommendation; static int players,card,runCount=0,hand1,hand2,dealer1,total,command=0; static Scanner input = new Scanner(System.in); public static void main(String[] args) { while ((command==0)||(command==1)) {//using a nested while so that we can keep the running count until the dealer shuffles while (command!=1) { System.out.println("Enter your card values one at a time, from 1 to 10"); h1Scanner(); h2Scanner(); System.out.println("Now enter the up card of the dealer, from 1 to 10"); d1Scanner();//Three scanner functions to read in the cards on the table recommend();//runs through a strategy list and recommends the correct strategy to the player System.out.println(recommendation); counter();//function that counts the cards during play and assists the player in the correct betting strategy System.out.println("Your running count is: "+runCount); if (runCount>0) { System.out.println("Recommends to bet more next round."); } if (runCount<0) { System.out.println("Recommends to bet less next round."); } if (runCount==0) { System.out.println("The odds are fairly even, bet how you feel."); } System.out.println("If the dealer reshuffled, enter the number 1. Otherwise, enter any other number"); command=input.nextInt(); } runCount=0; System.out.println("Enter any number, other than 1, when you are ready to begin again."); command=input.nextInt(); } input.close();

}

static String recommend() {
    total=hand1+hand2;
    if (dealer1==2) {
        if ((hand1==1)||(hand2==1)) {
            if (total==2) {
                recommendation="split";
            }
            if ((total>2)&&(total<8)) {
                recommendation="hit";
            }
            if (total==8) {
                recommendation="double if you can, otherwise stand"; 
            }
            if (total>8) {
                recommendation="stand";
            }
        }
        else {
            if ((hand1==hand2)&&(((total>0)&&(total<8))||((total>10)&&(total<20)))) {
                recommendation="Split";             
            }
            else {
                if (((total>4)&&(total<10))||(total==12)) {
                    recommendation="hit until over 12";
                }
                if ((total>9)&&(total<12)) {
                    recommendation="double";
                }
                if (total>12) {
                    recommendation="stand";
                }
            }
        }
    }
    if (dealer1==3) {
        if ((hand1==1)||(hand2==1)) {
            if (total==2) {
                recommendation="split";
            }
            if ((total>2)&&(total<7)) {
                recommendation="hit";
            }
            if (total==7) {
                recommendation="double";
            }
            if (total==8) {
                recommendation="double if you can, otherwise stand"; 
            }
            if (total>8) {
                recommendation="stand";
            }
        }
        else {
            if ((hand1==hand2)&&(((total>0)&&(total<8))||((total>10)&&(total<20)))) {
                    recommendation="Split";
            }
            else {
                if (((total>4)&&(total<9))||(total==12)) {
                    recommendation="hit until over 12";
                }
                if ((total>8)&&(total<12)) {
                    recommendation="double";
                }
                if (total>12) {
                    recommendation="stand";
                }
            }
        }
    }
    if (dealer1==4) {
        if ((hand1==1)||(hand2==1)) {
            if (total==2) {
                recommendation="split";
            }
            if ((total>2)&&(total<5)) {
                recommendation="hit";
            }
            if ((total>4)&&(total<8)) {
                recommendation="double";
            }
            if (total==8) {
                recommendation="double if you can, otherwise stand"; 
            }
            if (total>8) {
                recommendation="stand";
            }
        }
        else {
            if ((hand1==hand2)&&(((total>0)&&(total<8))||((total>10)&&(total<20)))) {
                    recommendation="Split";
            }
            else {
                if ((total>4)&&(total<9)) {
                    recommendation="hit until over 11";
                }
                if ((total>8)&&(total<12)) {
                    recommendation="double";
                }
                if (total>11) {
                    recommendation="stand";
                }
            }
        }
    }
    if (dealer1==5) {
        if ((hand1==1)||(hand2==1)) {
            if (total==2) {
                recommendation="split";
            }
            if ((total>2)&&(total<8)) {
                recommendation="double";
            }
            if (total==8) {
                recommendation="double if you can, otherwise stand"; 
            }
            if (total>8) {
                recommendation="stand";
            }
        }
        else {
            if ((hand1==hand2)&&(((total>0)&&(total<9))||((total>10)&&(total<20)))) {
                    recommendation="Split";
            }
            else {
                if ((total>4)&&(total<9)) {
                    recommendation="hit until over 11";
                }
                if ((total>8)&&(total<12)) {
                    recommendation="double";
                }
                if (total>11) {
                    recommendation="stand";
                }
            }
        }
    }
    if (dealer1==6) {
        if ((hand1==1)||(hand2==1)) {
            if (total==2) {
                recommendation="split";
            }
            if ((total>2)&&(total<8)) {
                recommendation="double";
            }
            if ((total>7)&&(total<10)) {
                recommendation="double if you can, otherwise stand"; 
            }
            if (total>9) {
                recommendation="stand";
            }
        }
        else {
            if ((hand1==hand2)&&(((total>0)&&(total<9))||((total>10)&&(total<20)))) {
                    recommendation="Split";
            }
            else {
                if ((total>4)&&(total<9)) {
                    recommendation="hit until over 11";
                }
                if ((total>8)&&(total<12)) {
                    recommendation="double";
                }
                if (total>11) {
                    recommendation="stand";
                }
            }
        }
    }
    if (dealer1==7) {             //Dealers hand
           if ((hand1==1)||(hand2==1)) {              //Aces
            if (total==2) {
             recommendation="split";
            }
            if ((total>2)&&(total<8)) {
             recommendation="hit";
            }
            if (total==10000) {
             recommendation="double if you can, otherwise stand";
            }
            if (total>7) {
             recommendation="stand";
            }
           }
           else {                           //non aces
               if ((hand1==8)&&(hand2==8)) { 
                   recommendation="split";
               }
               if ((hand1==7)&&(hand2==7)) {
                   recommendation="split";  
               }
               if ((hand1==3)&&(hand2==3)) {
                   recommendation="split";  
               }
               if ((hand1==2)&&(hand2==2)) {
                   recommendation="split";  
               }
               else { 
                   if ((total<10)||((total>11)&&(total<17))) {
                       recommendation="Hit until over 16";
                   }
                   if ((total==11)||(total==10)) {
                       recommendation="double if you can, otherwise hit";
                   }
                   if (total>16) {
                       recommendation="stand";
                   }
               }
           }
       }
       else
       if (dealer1==8) {             //Dealers hand
           if ((hand1==1)||(hand2==1)) {              //Aces
            if (total==2) {
             recommendation="split";
            }
            if ((total>2)&&(total<8)) {
             recommendation="hit";
            }
            if (total==10000) {
             recommendation="double if you can, otherwise stand";
            }
            if (total>7) {
             recommendation="stand";
            }
           }
           else {                           //non aces
               if ((hand1==8)&&(hand2==8)) { 
                   recommendation="split";
               }
               if ((hand1==9)&&(hand2==9)) {
                   recommendation="split";  
               }
               else { 
                   if ((total<10)||((total>11)&&(total<17))) {
                       recommendation="Hit until over 16";
                   }
                   if ((total==11)||(total==10)) {
                       recommendation="double if you can, otherwise hit";
                   }
                   if (total>16) {
                       recommendation="stand";
                   }
               }
           }
       }
       else
       if (dealer1==9) {             //Dealers hand
           if ((hand1==1)||(hand2==1)) {              //Aces
            if (total==2) {
             recommendation="split";
            }
            if ((total>2)&&(total<9)) {
             recommendation="hit";
            }
            if (total==10000) {
             recommendation="double if you can, otherwise stand";
            }
            if (total>8) {
             recommendation="stand";
            }
           }
           else {                           //non aces
               if ((hand1==8)&&(hand2==8)) { 
                   recommendation="split";
               }
               if ((hand1==9)&&(hand2==9)) {
                   recommendation="split";  
               }
               else { 
                   if ((total<10)||((total>11)&&(total<17))) {
                       recommendation="Hit until over 16";
                   }
                   if ((total==11)||(total==10)) {
                       recommendation="double if you can, otherwise hit";
                   }
                   if (total>16) {
                       recommendation="stand";
                   }
               }
           }
       }
       else
       if (dealer1==10) {             //Dealers hand
           if ((hand1==1)||(hand2==1)) {              //Aces
            if (total==2) {
             recommendation="split";
            }
            if ((total>2)&&(total<9)) {
             recommendation="hit";
            }
            if (total==10000) {
             recommendation="double if you can, otherwise stand";
            }
            if (total>8) {
             recommendation="stand";
            }
           }
           else {                           //non aces
               if ((hand1==8)&&(hand2==8)) { 
                   recommendation="split";
               }
               else { 
                   if ((total<11)||((total>11)&&(total<17))) {
                       recommendation="Hit until over 16";
                   }
                   if (total==11) {
                       recommendation="double if you can, otherwise hit";
                   }
                   if (total>16) {
                       recommendation="stand";
                   }
               }
           }
       }
       else
       if (dealer1==1) {             //Dealers hand
           if ((hand1==1)||(hand2==1)) {              //Aces
            if (total==2) {
             recommendation="split";
            }
            if ((total>2)&&(total<9)) {
             recommendation="hit";
            }
            if (total==10000) {
             recommendation="double if you can, otherwise stand";
            }
            if (total>8) {
             recommendation="stand";
            }
           }
           else {                           //non aces
               if ((hand1==8)&&(hand2==8)) { 
                   recommendation="split";
               }
               else { 
                   if ((total<11)||((total>11)&&(total<17))) {
                       recommendation="Hit until over 16";
                   }
                   if (total==11) {
                       recommendation="double if you can, otherwise hit";
                   }
                   if (total>16) {
                       recommendation="stand";
                   }
               }
           }
       }
    return recommendation;
}

static int h1Scanner() {
    hand1=input.nextInt();
    return hand1;
}
static int h2Scanner() {
    hand2=input.nextInt();
    return hand2;
}
static int d1Scanner() {
    dealer1=input.nextInt();
    return dealer1;
}
static int counter() {
    System.out.println("When finished, enter all cards that were on the table that round from 1 to 10. Enter an 11 when you are finished.");
    card=0;
    while (card!=11) {
        card=input.nextInt();
        if ((card==10)||(card==1)) {
            runCount--;
        }
        if ((card>1)&&(card<7)) {
            runCount++;
        }
        if ((card>6)&&(card<10)) {
            runCount=runCount+0;
        }
    }
    return runCount;
}

}

Built With

Share this project:
×

Updates