I'm working on a program to simulate a game of blackjack and I'm a bit stuck. I want to have a running score that would be "score + value" after each card is dealt, I know I'm going the wrong way about it but just can't figure it out, any help is greatly appreciated!
import java.util.Scanner;
import java.util.Random;
class blackjack{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int value, score=0;
String card1, card2, card3, card4, card5, play1, play2, play3;
Random random = new Random();
String[] suit = {"Spades", "Hearts", "Clubs", "Diamonds"};
int selectS = random.nextInt(suit.length);
String[] rank = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};
int selectR = random.nextInt(rank.length);
card1 = (rank[selectR] + " of " + suit[selectS]);
card2 = (rank[selectR] + " of " + suit[selectS]);
card3 = (rank[selectR] + " of " + suit[selectS]);
card4 = (rank[selectR] + " of " + suit[selectS]);
card5 = (rank[selectR] + " of " + suit[selectS]);
if(selectR >=9 ) {
value = 10;
}
if(selectR ==0 && score < 22) {
value = 11;
}
if(selectR ==0 && score > 21){
value = 1;
}
if(selectR >0 && selectR<9 ) {
value = selectR+1;
}
System.out.println(card1);
System.out.println(card2+"\nRunning score : "+score);
System.out.print("\nHit or stay?");
play1 = in.nextLine();
if(play1.equals("hit")){
System.out.println(card3+"\nRunning score : "+score);
}
System.out.print("\nHit or stay?");
play2 = in.nextLine();
if(play2.equals("hit")){
System.out.println(card4+"\nRunning score : "+score);
}
System.out.print("\nHit or stay?");
play3 = in.nextLine();
if(play3.equals("hit")){
System.out.println(card5+"\nRunning score : "+score);
}
} //end main
} //end class