Assignemnt #89

Code

    Name: Mahima Choudhary
    Period: 6
    Project Name: BaBl
    File Name: BaBl.java
    Date: 2/11/2015
    
import java.util.Random;


public class BaBl
{
	public static void main( String[] args )
	{
		System.out.println("Let's play Baby Blackjack!");

		int[] cards = new int[4];

		Random r = new Random();

		for (int i = 0; i < 4; i++)
		{
			cards[i] = r.nextInt(10)+1;
		}

		System.out.println("You drew "+cards[0]+" and "+cards[1]+".");
		System.out.println("Your total is "+(cards[0]+cards[1])+"." );

		System.out.println("The dealer drew "+cards[2]+" and "+cards[3]+".");
		System.out.println("His total is "+(cards[2]+cards[3])+"." );

		if ( (cards[0]+cards[1]) > (cards[2]+cards[3]) ) System.out.println("You win!!");
		else if ( (cards[0]+cards[1]) < (cards[2]+cards[3]) ) System.out.println("You lose!!");
		else System.out.println("It's a tie!!");
	}
}


    

Picture of the output

Assignment 86