I'm fairly new to java and need help with adding letters (J, Q, K, A) into the program and adding values for each. Thanks.
Code:
// February 8, 2008
// The "BlackJack" class.
import java.awt.*;
import hsa.Console;
import java.util.Random; // Only the Random class
import java.util.*; // All classes in the java.util package
public class BlackJack
{
static Console c; // The output console
public static void main (String[] args)
{
c = new Console ();
char another;
c.println("******************");
c.println("B-L-A-C-K-J-A-C-K");
c.println("******************");
c.println ("Your Cards:");
int n = (int)(10.0 * Math.random()) + 1;
int m = (int)(10.0 * Math.random()) + 1;
c.print ("|" + n);
c.println ("| |" + m + "|");
int total;
total = n+m;
c.println ("You now have " + total);
if (total <=21)
{
c.println ();
c.print ("Do you want another? (y/n) ");
another = c.readChar();
if (another == 'y' | another == 'Y')
{
int a = (int)(10.0 * Math.random()) + 1;
c.println ("You have added the card " + a);
c.println ("You now have in total " + (n+m+a));
}
else if (total >21)
{
c.println ();
c.print ("Your busted!");
}
}
} // main method
} // BlackJack class
Comment