Assignment #89: Baby Blackjack
Code
import java.util.Random;
public class BabyBlackjack {
public static void main (String[] args) {
Random r = new Random();
int pdraw1 = 1 + r.nextInt(10);
int pdraw2 = 1 + r.nextInt(10);
int ddraw1 = 1 + r.nextInt(10);
int ddraw2 = 1 + r.nextInt(10);
System.out.println("You drew " + pdraw1 + " and " + pdraw2 + ".");
System.out.println("The dealer drew " + ddraw1 + " and " + ddraw2 + ".");
if ((ddraw1 + ddraw2) >= (pdraw1 + pdraw2)) {
System.out.println("Sorry! You lose.");
}
else {
System.out.println("Congratulations! You win!");
}
}
}
Picture of the output