Assignment 89; BlackjackLite
Code
// Donovan Rich
// Period 6
// Baby Blackjack
// BlackjackLite.java
// 2/29/2016
import java.util.Random;
public class BlackjackLite
{
public static void main ( String[] args )
{
Random r = new Random();
int deal = 1 + r.nextInt(10), play = 1 + r.nextInt(10), dTotal, pTotal;
System.out.println( "You are dealt a " + play);
pTotal = play;
System.out.println( "The dealer is dealt a " + deal );
dTotal = deal;
play = 1 + r.nextInt(10);
System.out.println( "You are dealt a " + play);
pTotal += play;
deal = 1 + r.nextInt(10);
System.out.println( "The dealer is dealt a " + deal );
dTotal += deal;
System.out.println( "Your hand is worth " + pTotal );
System.out.println( "The dealer's is worth " + dTotal );
if ( dTotal < pTotal )
System.out.println( "You win!" );
else if ( dTotal > pTotal )
System.out.println( "You lose.");
else
System.out.println( "You tie." );
}
}
Picture of the output