jeudi 29 janvier 2015

Program Not Calculating Properly Given All Variables

[Still Learning...] While trying to create a program to calculate the advantage/disadvantage of a blackjack table given all rule variations, this calculator only displays the initial input from the user for the number of decks. All of the other rules from the user seem to be completely ignored when it is run. For example, with 6-decks, the result is always -0.54% regardless of whatever you enter for the rest of the rules. It only takes into account the number of decks. How do I resolve this issue? The code is here:



{ public static void main(String[] args){ double edge = 0;

Scanner sc = new Scanner(System.in);
System.out.println("How many decks (1, 2, 4, 6, 8)");
int decks = sc.nextInt();
System.out.println("Dealer hits Soft 17 (Y or N)");
String soft17 = sc.next();
System.out.println("Double after splits (Y or N)");
String doubleAfterSplit = sc.next();
System.out.println("Double 10/11 only (Y or N)");
String double1011 = sc.next();
System.out.println("Double 9/10/11 only (Y or N)");
String double91011 = sc.next();
System.out.println("Resplit Aces (Y or N)");
String rSA = sc.next();
System.out.println("Late Surrender (Y or N)");
String lateSurrender = sc.next();
System.out.println("Early Surrender (Y or N)");
String earlySurrender = sc.next();
System.out.println("Lose all doubles/splits vs. Natural (Y or N)");
String loseAllDS = sc.next();
sc.close();

//Number of Decks Option
if (decks == 1) {
edge += 0.01;
} else if (decks == 2) {
edge -= 0.32;
} else if (decks == 4) {
edge -= 0.49;
} else if (decks == 6) {
edge -= 0.54;
} else if (decks == 8) {
edge -= 0.57;
} else {
System.out.println("You made a mistake. Start over.");
}

//Soft 17 Options
if (soft17 == "Y") {
edge -= 0.20;
} else {
edge += 0;
}

//Double After Splits Option
if (doubleAfterSplit == "Y") {
edge += 0.14;
} else {
edge += 0;
}

//Double 10 and 11 Only Option
if (double1011 == "Y") {
edge -= 0.17;
} else {
edge += 0;
}

//Double 9, 10, and 11 Only Option
if (double91011 == "Y") {
edge -= 0.08;
} else {
edge += 0;
}

//Resplit Aces Option
if (rSA == "Y") {
edge += 0.08;
} else {
edge += 0;
}

//Late Surrender Option
if (lateSurrender == "Y") {
edge += 0.08;
} else {
edge += 0;
}

//Early Surrender Option
if (earlySurrender =="Y") {
edge += 0.65;
} else {
edge += 0;
}

//Lose on All Doubles and Splits vs Natural Option
if (loseAllDS == "Y") {
edge -= 0.11;
} else {
edge += 0;
}

if (edge >= 0) {
System.out.println("Your advantage is: " + edge + "%");
} else {
System.out.println("Your disadgantage is: " + edge + "%");
}


}

Aucun commentaire:

Enregistrer un commentaire