PROGRAMMING AND CODE


Assignemnt #89

Code

/// Name: Justin Li
/// Period: 7
/// Program Name: BabyBlackjack
/// File Name: BabyBlackjack.java
/// Date Completed: 2/22/16

 import java.util.Random;
    
    public class BabyBlackjack {
    
        public static void main(String[] args) throws Exception {
        
            Random r = new Random();
            
            int a = (1+r.nextInt(10));
            int b = (1+r.nextInt(10));
            int c = (1+r.nextInt(10));
            int d = (1+r.nextInt(10));
            
            System.out.println("Baby Blackjack");
            
            System.out.print("\nYou drew ");
            Thread.sleep(750);
            System.out.print(a);
            Thread.sleep(750);
            System.out.print(" and ");
            Thread.sleep(750);
            System.out.println(b + ".");
            Thread.sleep(500);
            System.out.println("Your total is " + (a+b));
            
            Thread.sleep(1000);
            
            System.out.print("\nThe dealer has ");
            Thread.sleep(750);
            System.out.print(c);
            Thread.sleep(750);
            System.out.print(" and ");
            Thread.sleep(750);
            System.out.println(d + ".");
            Thread.sleep(500);
            System.out.println("Dealer's total is " + (c+d));
            
            Thread.sleep(1000);
            
            System.out.println();
            
            if (a + b > c + d)
                System.out.println("You win.");
            else if (a + b < c + d)
                System.out.println("Dealer wins.");
            else if (a + b == c + d)
                System.out.println("Tie.");
            else
                System.out.println("??");
        }
    }
    
    

Picture of the output

Assignment 1